-
Notifications
You must be signed in to change notification settings - Fork 7
/
tests.py
36 lines (28 loc) · 1.13 KB
/
tests.py
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
import unittest
from pyui.env import Environment
from pyui.font import Font
from pyui.geom import Insets, Point, Rect, Size
from pyui.utils import enumerate_last
class MeasurementTests(unittest.TestCase):
def test_rect_insets(self):
r1 = Rect(origin=(100, 100), size=(150, 50))
r2 = r1 + Insets(10)
self.assertEqual(r2.origin, Point(90, 90))
self.assertEqual(r2.size, Size(170, 70))
r3 = r1 - Insets(10)
self.assertEqual(r3.origin, Point(110, 110))
self.assertEqual(r3.size, Size(130, 30))
def test_enumerate_last(self):
values = list(enumerate_last([100, 200, 300]))
self.assertEqual(values, [(0, 100, False), (1, 200, False), (2, 300, True)])
self.assertEqual(list(enumerate_last([])), [])
class EnvironmentTests(unittest.TestCase):
def test_inheritance(self):
parent = Environment(font_size=24)
child = Environment()
self.assertEqual(child.font_size, Environment.font_size.default)
child.inherit(parent)
self.assertEqual(child.font_size, 24)
if __name__ == "__main__":
Font.initialize(1.0)
unittest.main()