[Python-checkins] bpo-41831: Add tests for tkinter.Event.__repr__ (GH-22354) (GH-22617)
Miss Skeleton (bot)
webhook-mailer at python.org
Fri Oct 9 15:56:28 EDT 2020
https://github.com/python/cpython/commit/43c3eafa1bcdc522870e112d3e2d67ce2451c34b
commit: 43c3eafa1bcdc522870e112d3e2d67ce2451c34b
branch: 3.9
author: Miss Skeleton (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-10-09T22:56:19+03:00
summary:
bpo-41831: Add tests for tkinter.Event.__repr__ (GH-22354) (GH-22617)
(cherry picked from commit f25323a307a72c40862c87c2df822f83be6645da)
Co-authored-by: Serhiy Storchaka <storchaka at gmail.com>
files:
M Lib/tkinter/test/test_tkinter/test_misc.py
diff --git a/Lib/tkinter/test/test_tkinter/test_misc.py b/Lib/tkinter/test/test_tkinter/test_misc.py
index 1e089747a91ee..b8eea2544f522 100644
--- a/Lib/tkinter/test/test_tkinter/test_misc.py
+++ b/Lib/tkinter/test/test_tkinter/test_misc.py
@@ -192,6 +192,54 @@ def test_clipboard_astral(self):
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, )
More information about the Python-checkins
mailing list