1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import random
20 import unittest
21
22 import wx
23
24 from timelinelib.calendar.gregorian.timetype import GregorianTimeType
25
26
28
29 HALT_GUI = False
30 AUTO_CLOSE = False
31
33 message = "Periods not equal.\n First: %s \"%s\"\n Second: %s \"%s\"" % (
34 first,
35 time_type.format_period(first),
36 second,
37 time_type.format_period(second),
38 )
39 self.assertEqual(first, second, message)
40
42 for element in list_:
43 if element is object_:
44 self.fail("%r was in list" % object_)
45
47 (modification_description, modifier_fn) = get_random_modifier(modifiers)
48 one = modifier_fn(create_fn())
49 other = modifier_fn(create_fn())
50 fail_message_one_other = "%r vs %r (%s)" % (one, other,
51 modification_description)
52 self.assertTrue(type(one) == type(other), fail_message_one_other)
53 self.assertFalse(one is None, fail_message_one_other)
54 self.assertTrue(one is not None, fail_message_one_other)
55 self.assertTrue(one is not other, fail_message_one_other)
56 self.assertFalse(one is other, fail_message_one_other)
57 self.assertTrue(one == other, fail_message_one_other)
58 self.assertFalse(one != other, fail_message_one_other)
59 self.assertTrue(one == one, fail_message_one_other)
60 self.assertFalse(one != one, fail_message_one_other)
61 (modification_description, modifier_fn) = get_random_modifier(modifiers)
62 modified = modifier_fn(other)
63 fail_message_modified_one = "%r vs %r (%s)" % (modified, one,
64 modification_description)
65 self.assertTrue(type(modified) == type(one), fail_message_modified_one)
66 self.assertTrue(modified is not one, fail_message_modified_one)
67 self.assertFalse(modified is one, fail_message_modified_one)
68 self.assertTrue(modified != one, fail_message_modified_one)
69 self.assertFalse(modified == one, fail_message_modified_one)
70
72 app = self.get_wxapp()
73 try:
74 dialog = dialog_class(*args, **kwargs)
75 try:
76 if self.HALT_GUI:
77 if self.AUTO_CLOSE:
78 wx.CallLater(2000, dialog.Close)
79 dialog.ShowModal()
80 finally:
81 dialog.Destroy()
82 finally:
83 if app.GetTopWindow():
84 app.GetTopWindow().Destroy()
85 app.Destroy()
86
88 app = wx.App(False)
89 import locale
90 locale.setlocale(locale.LC_ALL, 'C')
91 self.locale = wx.Locale()
92 self.locale.Init(wx.LANGUAGE_DEFAULT)
93 return app
94
95
97 return random.choice(modifiers)
98