1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import contextlib
20 import gc
21 import random
22 import unittest
23
24 import wx
25
26 from timelinelib.calendar.gregorian.timetype import GregorianTimeType
27 from timelinelib.test.utils import svg_to_dict
31
32 HALT_GUI = False
33 AUTO_CLOSE = False
34
37
39 message = "Periods not equal.\n First: %s \"%s\"\n Second: %s \"%s\"" % (
40 first,
41 time_type.format_period(first),
42 second,
43 time_type.format_period(second),
44 )
45 self.assertEqual(first, second, message)
46
48 for element in list_:
49 if element is object_:
50 self.fail("%r was in list" % object_)
51
53 (modification_description, modifier_fn) = get_random_modifier(modifiers)
54 one = modifier_fn(create_fn())
55 other = modifier_fn(create_fn())
56 fail_message_one_other = "%r vs %r (%s)" % (one, other,
57 modification_description)
58 self.assertTrue(type(one) == type(other), fail_message_one_other)
59 self.assertFalse(one is None, fail_message_one_other)
60 self.assertTrue(one is not None, fail_message_one_other)
61 self.assertTrue(one is not other, fail_message_one_other)
62 self.assertFalse(one is other, fail_message_one_other)
63 self.assertTrue(one == other, fail_message_one_other)
64 self.assertFalse(one != other, fail_message_one_other)
65 self.assertTrue(one == one, fail_message_one_other)
66 self.assertFalse(one != one, fail_message_one_other)
67 (modification_description, modifier_fn) = get_random_modifier(modifiers)
68 modified = modifier_fn(other)
69 fail_message_modified_one = "%r vs %r (%s)" % (modified, one,
70 modification_description)
71 self.assertTrue(type(modified) == type(one), fail_message_modified_one)
72 self.assertTrue(modified is not one, fail_message_modified_one)
73 self.assertFalse(modified is one, fail_message_modified_one)
74 self.assertTrue(modified != one, fail_message_modified_one)
75 self.assertFalse(modified == one, fail_message_modified_one)
76
78 with self.wxapp() as app:
79 dialog = dialog_class(*args, **kwargs)
80 try:
81 if self.HALT_GUI:
82 if self.AUTO_CLOSE:
83 wx.CallLater(2000, dialog.Close)
84 dialog.ShowModal()
85 finally:
86 dialog.Destroy()
87
88 @contextlib.contextmanager
95
98
100 if app.GetTopWindow():
101 app.GetTopWindow().Destroy()
102 app.Destroy()
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117 gc.collect()
118
121 return random.choice(modifiers)
122