forked from slightlynybbled/tk_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_SmartCheckbutton.py
More file actions
54 lines (33 loc) · 860 Bytes
/
test_SmartCheckbutton.py
File metadata and controls
54 lines (33 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import tkinter as tk
import pytest
from tk_tools import SmartCheckbutton
from tests.test_basic import root
@pytest.fixture
def scb(root):
scb_widget = SmartCheckbutton(root)
scb_widget.grid()
yield scb_widget
def test_creation(root):
SmartCheckbutton(root)
def test_callback(root):
item_value = 0
def callback():
nonlocal item_value
item_value += 1
scb = SmartCheckbutton(root, callback=callback)
scb.grid()
scb.set(True)
scb.set(False)
scb.set(True)
assert item_value == 3
def test_callback_with_parameter(root):
item_value = 0
def callback(value):
nonlocal item_value
item_value += 2 if value else 0
scb = SmartCheckbutton(root, callback=callback)
scb.grid()
scb.set(True)
scb.set(False)
scb.set(True)
assert item_value == 4