ยปCore Development>Code coverage>Lib/tkinter/test/test_tkinter/test_misc.py

Python code coverage for Lib/tkinter/test/test_tkinter/test_misc.py

#countcontent
1n/aimport unittest
2n/aimport tkinter
3n/afrom test import support
4n/afrom tkinter.test.support import AbstractTkTest
5n/a
6n/asupport.requires('gui')
7n/a
8n/aclass MiscTest(AbstractTkTest, unittest.TestCase):
9n/a
10n/a def test_repr(self):
11n/a t = tkinter.Toplevel(self.root, name='top')
12n/a f = tkinter.Frame(t, name='child')
13n/a self.assertEqual(repr(f), '<tkinter.Frame object .top.child>')
14n/a
15n/a def test_generated_names(self):
16n/a t = tkinter.Toplevel(self.root)
17n/a f = tkinter.Frame(t)
18n/a f2 = tkinter.Frame(t)
19n/a b = tkinter.Button(f2)
20n/a for name in str(b).split('.'):
21n/a self.assertFalse(name.isidentifier(), msg=repr(name))
22n/a
23n/a def test_tk_setPalette(self):
24n/a root = self.root
25n/a root.tk_setPalette('black')
26n/a self.assertEqual(root['background'], 'black')
27n/a root.tk_setPalette('white')
28n/a self.assertEqual(root['background'], 'white')
29n/a self.assertRaisesRegex(tkinter.TclError,
30n/a '^unknown color name "spam"$',
31n/a root.tk_setPalette, 'spam')
32n/a
33n/a root.tk_setPalette(background='black')
34n/a self.assertEqual(root['background'], 'black')
35n/a root.tk_setPalette(background='blue', highlightColor='yellow')
36n/a self.assertEqual(root['background'], 'blue')
37n/a self.assertEqual(root['highlightcolor'], 'yellow')
38n/a root.tk_setPalette(background='yellow', highlightColor='blue')
39n/a self.assertEqual(root['background'], 'yellow')
40n/a self.assertEqual(root['highlightcolor'], 'blue')
41n/a self.assertRaisesRegex(tkinter.TclError,
42n/a '^unknown color name "spam"$',
43n/a root.tk_setPalette, background='spam')
44n/a self.assertRaisesRegex(tkinter.TclError,
45n/a '^must specify a background color$',
46n/a root.tk_setPalette, spam='white')
47n/a self.assertRaisesRegex(tkinter.TclError,
48n/a '^must specify a background color$',
49n/a root.tk_setPalette, highlightColor='blue')
50n/a
51n/a
52n/atests_gui = (MiscTest, )
53n/a
54n/aif __name__ == "__main__":
55n/a support.run_unittest(*tests_gui)