2013-01-01 18:03:58 -04:00
|
|
|
import unittest
|
|
|
|
import tkinter
|
|
|
|
from test import support
|
2014-08-24 03:07:47 -03:00
|
|
|
from tkinter.test.support import AbstractTkTest
|
2013-01-01 18:03:58 -04:00
|
|
|
|
|
|
|
support.requires('gui')
|
|
|
|
|
2014-08-24 03:07:47 -03:00
|
|
|
class MiscTest(AbstractTkTest, unittest.TestCase):
|
2013-01-01 18:03:58 -04:00
|
|
|
|
2014-04-04 09:45:02 -03:00
|
|
|
def test_repr(self):
|
|
|
|
t = tkinter.Toplevel(self.root, name='top')
|
|
|
|
f = tkinter.Frame(t, name='child')
|
|
|
|
self.assertEqual(repr(f), '<tkinter.Frame object .top.child>')
|
|
|
|
|
2013-01-01 18:03:58 -04:00
|
|
|
def test_tk_setPalette(self):
|
|
|
|
root = self.root
|
|
|
|
root.tk_setPalette('black')
|
|
|
|
self.assertEqual(root['background'], 'black')
|
|
|
|
root.tk_setPalette('white')
|
|
|
|
self.assertEqual(root['background'], 'white')
|
|
|
|
self.assertRaisesRegex(tkinter.TclError,
|
|
|
|
'^unknown color name "spam"$',
|
|
|
|
root.tk_setPalette, 'spam')
|
|
|
|
|
|
|
|
root.tk_setPalette(background='black')
|
|
|
|
self.assertEqual(root['background'], 'black')
|
|
|
|
root.tk_setPalette(background='blue', highlightColor='yellow')
|
|
|
|
self.assertEqual(root['background'], 'blue')
|
|
|
|
self.assertEqual(root['highlightcolor'], 'yellow')
|
|
|
|
root.tk_setPalette(background='yellow', highlightColor='blue')
|
|
|
|
self.assertEqual(root['background'], 'yellow')
|
|
|
|
self.assertEqual(root['highlightcolor'], 'blue')
|
|
|
|
self.assertRaisesRegex(tkinter.TclError,
|
|
|
|
'^unknown color name "spam"$',
|
|
|
|
root.tk_setPalette, background='spam')
|
|
|
|
self.assertRaisesRegex(tkinter.TclError,
|
|
|
|
'^must specify a background color$',
|
|
|
|
root.tk_setPalette, spam='white')
|
|
|
|
self.assertRaisesRegex(tkinter.TclError,
|
|
|
|
'^must specify a background color$',
|
|
|
|
root.tk_setPalette, highlightColor='blue')
|
|
|
|
|
|
|
|
|
|
|
|
tests_gui = (MiscTest, )
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
support.run_unittest(*tests_gui)
|