Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_enable():
a = App()
w = Waffle(a)
enable_test(w)
a.destroy()
def test_repeat_schedule():
a = App()
w = Waffle(a)
schedule_repeat_test(a, w)
a.destroy()
def test_color():
a = App()
w = Waffle(a)
color_test(w)
a.destroy()
def test_grid_layout():
a = App(layout="grid")
w = Waffle(a, grid=[1,2])
grid_layout_test(w, 1, 2, 1, 1, None)
ws = Waffle(a, grid=[1,2,3,4])
grid_layout_test(ws, 1, 2, 3, 4, None)
wa = Waffle(a, grid=[1,2], align="top")
grid_layout_test(wa, 1, 2, 1, 1, "top")
a.destroy()
def test_default_values():
a = App()
w = Waffle(a)
assert w.master == a
assert w.grid == None
assert w.align == None
assert w.width == 3
assert w.height == 3
assert w.pixel_size == 20
assert w.pad == 5
assert w.color == "white"
assert w.dotty == False
a.destroy()
def test_reset():
from itertools import chain
a = App()
w = Waffle(a)
w.set_pixel(0, 1, "red")
w.reset()
pixels = chain.from_iterable(zip(*w.get_all()))
count = 0
for pixel in pixels:
assert pixel == w.color
count += 1
assert count == w.width * w.height
a.destroy()
def test_set_get_pixel():
a = App()
w = Waffle(a)
w.set_pixel(0,0, "red")
assert w.get_pixel(0,0) == "red"
a.destroy()
def test_command():
a = App()
callback_event = Event()
def callback():
callback_event.set()
w = Waffle(a, command = callback)
assert not callback_event.is_set()
mock_waffle_clicked(w)
assert callback_event.is_set()
a.destroy()
def test_command_with_parameters():
a = App()
callback_event = Event()
def callback(x, y):
assert x == 0
assert y == 1
callback_event.set()
w = Waffle(a, command = callback)
assert not callback_event.is_set()
mock_waffle_clicked(w)
assert callback_event.is_set()
a.destroy()
def test_update_command_with_parameters():
a = App()
callback_event = Event()
def callback(x, y):
assert x == 0
assert y == 1
callback_event.set()
w = Waffle(a)
w.update_command(callback)
mock_waffle_clicked(w)
assert callback_event.is_set()
a.destroy()