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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
import pytest
from threading import Event
from guizero import App, Text, Picture, system_config
from common_test import (
schedule_after_test,
schedule_repeat_test,
display_test,
events_test,
cascading_enable_test,
cascading_properties_test,
inheriting_properties_test,
full_screen_test,
add_tk_widget_test,
icon_test)
def test_default_values():
a = App()
assert a.title == "guizero"
assert a.width == 500
assert a.height == 500
assert a.layout == "auto"
assert a.description > ""
a.destroy()
def test_alt_values():
a = App(title = "foo", width = 666, height = 666, layout="grid")
assert a.title == "foo"
assert a.width == 666
assert a.height == 666
assert a.layout == "grid"
a.destroy()
def test_getters_setters():
a = App()
a.title = "bar"
assert a.title == "bar"
a.bg = "red"
assert a.bg == "red"
a.height = 666
assert a.height == 666
a.width = 666
assert a.width == 666
a.destroy()
def test_update():
a = App()
# just testing it doesnt fail
a.update()
a.destroy()
def test_after_schedule():
a = App()
schedule_after_test(a, a)
a.destroy()
def test_repeat_schedule():
a = App()
schedule_repeat_test(a, a)
a.destroy()
def test_display():
a = App()
display_test(a)
a.destroy()
def test_enable():
a = App()
t = Text(a)
cascading_enable_test(a)
a.destroy()
def test_events():
a = App()
events_test(a)
a.destroy()
def test_when_resized():
a = App()
resize_event = Event()
def callback():
resize_event.set()
def callback_params(event):
assert event.width == 503
assert event.height == 504
resize_event.set()
a.when_resized = callback
a.resize(501, 502)
assert resize_event.wait(1)
resize_event.clear()
a.when_resized = callback_params
a.resize(503, 504)
assert resize_event.wait(1)
resize_event.clear()
a.when_resized = None
a.resize(505, 506)
assert not resize_event.wait(0.1)
a.destroy()
def test_cascading_properties():
a = App()
cascading_properties_test(a)
a.destroy()
def test_inheriting_properties():
a = App()
inheriting_properties_test(a)
a.destroy()
def test_full_screen():
a = App()
full_screen_test(a)
a.destroy()
def test_add_tk_widget():
a = App()
add_tk_widget_test(a)
a.destroy()
def test_icon():
a = App()
icon_test(a, "tests/guizero.gif")
a.destroy()
@pytest.mark.skipif(system_config.PIL_available == False,
reason="PIL not available")
def test_icon_jpg():
a = App()
icon_test(a, "tests/guizero.jpg")
a.destroy()
|