forked from slightlynybbled/tk_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_ButtonGrid.py
More file actions
60 lines (40 loc) · 1.24 KB
/
test_ButtonGrid.py
File metadata and controls
60 lines (40 loc) · 1.24 KB
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
54
55
56
57
58
59
60
import tkinter as tk
import pytest
from tk_tools import ButtonGrid
from tests.test_basic import root
@pytest.fixture
def btn_grid_3col(root):
eg = ButtonGrid(root, 3, headers=['a', 'b', 'c'])
yield eg
eg._redraw()
def test_creation_with_header(root):
ButtonGrid(root, 3, headers=['a', 'b', 'c'])
def test_header_len_doesnt_match_cols(root):
with pytest.raises(ValueError):
ButtonGrid(root, 2, headers=['a', 'b', 'c'])
def test_add_row(btn_grid_3col):
data = [
('1', lambda: print('1')),
('2', lambda: print('2')),
('3', lambda: print('3')),
]
btn_grid_3col.add_row(data)
def test_add_row_wrong_format(btn_grid_3col):
data = ['1', '2', '3']
with pytest.raises(ValueError):
btn_grid_3col.add_row(data)
def test_add_row_len_doesnt_match_cols(btn_grid_3col):
data = ['1', '2', '3', '4']
with pytest.raises(ValueError):
btn_grid_3col.add_row(data)
def test_remove_row(btn_grid_3col):
data = [
('1', lambda: print('1')),
('2', lambda: print('2')),
('3', lambda: print('3')),
]
btn_grid_3col.add_row(data)
btn_grid_3col.add_row(data)
btn_grid_3col.add_row(data)
# remove row 1
btn_grid_3col.remove_row(1)