diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2020-10-09 18:45:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-09 18:45:46 (GMT) |
commit | f25323a307a72c40862c87c2df822f83be6645da (patch) | |
tree | 1a562cd6db2b4a376923b9fa7c2a2e4a56feb607 /Lib/tkinter | |
parent | e2ec0b27c02a158d0007c11dcc1f2d7a95948712 (diff) | |
download | cpython-f25323a307a72c40862c87c2df822f83be6645da.zip cpython-f25323a307a72c40862c87c2df822f83be6645da.tar.gz cpython-f25323a307a72c40862c87c2df822f83be6645da.tar.bz2 |
bpo-41831: Add tests for tkinter.Event.__repr__ (GH-22354)
Diffstat (limited to 'Lib/tkinter')
-rw-r--r-- | Lib/tkinter/test/test_tkinter/test_misc.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Lib/tkinter/test/test_tkinter/test_misc.py b/Lib/tkinter/test/test_tkinter/test_misc.py index 1e08974..b8eea25 100644 --- a/Lib/tkinter/test/test_tkinter/test_misc.py +++ b/Lib/tkinter/test/test_tkinter/test_misc.py @@ -192,6 +192,54 @@ class MiscTest(AbstractTkTest, unittest.TestCase): with self.assertRaises(tkinter.TclError): root.clipboard_get() + def test_event_repr_defaults(self): + e = tkinter.Event() + e.serial = 12345 + e.num = '??' + e.height = '??' + e.keycode = '??' + e.state = 0 + e.time = 123456789 + e.width = '??' + e.x = '??' + e.y = '??' + e.char = '' + e.keysym = '??' + e.keysym_num = '??' + e.type = '100' + e.widget = '??' + e.x_root = '??' + e.y_root = '??' + e.delta = 0 + self.assertEqual(repr(e), '<100 event>') + + def test_event_repr(self): + e = tkinter.Event() + e.serial = 12345 + e.num = 3 + e.focus = True + e.height = 200 + e.keycode = 65 + e.state = 0x30405 + e.time = 123456789 + e.width = 300 + e.x = 10 + e.y = 20 + e.char = 'A' + e.send_event = True + e.keysym = 'Key-A' + e.keysym_num = ord('A') + e.type = tkinter.EventType.Configure + e.widget = '.text' + e.x_root = 1010 + e.y_root = 1020 + e.delta = -1 + self.assertEqual(repr(e), + "<Configure event send_event=True" + " state=Shift|Control|Button3|0x30000" + " keysym=Key-A keycode=65 char='A'" + " num=3 delta=-1 focus=True" + " x=10 y=20 width=300 height=200>") tests_gui = (MiscTest, ) |