summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tkinter/test_misc.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-12-06 15:12:37 (GMT)
committerGitHub <noreply@github.com>2023-12-06 15:12:37 (GMT)
commitf189bd3e839f95396ca4db3295883976c510ef0d (patch)
tree71ec21fdf3728bc57e5b40bfbe34fb0093cdbb6f /Lib/test/test_tkinter/test_misc.py
parent399a3f2e1e428710fa4dc5c54841e179dc8e1028 (diff)
downloadcpython-f189bd3e839f95396ca4db3295883976c510ef0d.zip
cpython-f189bd3e839f95396ca4db3295883976c510ef0d.tar.gz
cpython-f189bd3e839f95396ca4db3295883976c510ef0d.tar.bz2
[3.12] gh-75666: Tkinter: "unbind(sequence, funcid)" now only unbinds "funcid" (GH-111322) (GH-112802)
Previously, "widget.unbind(sequence, funcid)" destroyed the current binding for "sequence", leaving "sequence" unbound, and deleted the "funcid" command. Now it removes only "funcid" from the binding for "sequence", keeping other commands, and deletes the "funcid" command. It leaves "sequence" unbound only if "funcid" was the last bound command. (cherry picked from commit cc7e45cc572dd818412a649970fdee579417701f) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: GiovanniL <13402461+GiovaLomba@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_tkinter/test_misc.py')
-rw-r--r--Lib/test/test_tkinter/test_misc.py34
1 files changed, 27 insertions, 7 deletions
diff --git a/Lib/test/test_tkinter/test_misc.py b/Lib/test/test_tkinter/test_misc.py
index bac52ae..a84bb02 100644
--- a/Lib/test/test_tkinter/test_misc.py
+++ b/Lib/test/test_tkinter/test_misc.py
@@ -425,26 +425,46 @@ class BindTest(AbstractTkTest, unittest.TestCase):
def test_unbind2(self):
f = self.frame
+ f.wait_visibility()
+ f.focus_force()
+ f.update_idletasks()
event = '<Control-Alt-Key-c>'
self.assertEqual(f.bind(), ())
self.assertEqual(f.bind(event), '')
- def test1(e): pass
- def test2(e): pass
+ def test1(e): events.append('a')
+ def test2(e): events.append('b')
+ def test3(e): events.append('c')
funcid = f.bind(event, test1)
funcid2 = f.bind(event, test2, add=True)
+ funcid3 = f.bind(event, test3, add=True)
+ events = []
+ f.event_generate(event)
+ self.assertEqual(events, ['a', 'b', 'c'])
- f.unbind(event, funcid)
+ f.unbind(event, funcid2)
script = f.bind(event)
- self.assertNotIn(funcid, script)
- self.assertCommandNotExist(funcid)
- self.assertCommandExist(funcid2)
+ self.assertNotIn(funcid2, script)
+ self.assertIn(funcid, script)
+ self.assertIn(funcid3, script)
+ self.assertEqual(f.bind(), (event,))
+ self.assertCommandNotExist(funcid2)
+ self.assertCommandExist(funcid)
+ self.assertCommandExist(funcid3)
+ events = []
+ f.event_generate(event)
+ self.assertEqual(events, ['a', 'c'])
- f.unbind(event, funcid2)
+ f.unbind(event, funcid)
+ f.unbind(event, funcid3)
self.assertEqual(f.bind(event), '')
self.assertEqual(f.bind(), ())
self.assertCommandNotExist(funcid)
self.assertCommandNotExist(funcid2)
+ self.assertCommandNotExist(funcid3)
+ events = []
+ f.event_generate(event)
+ self.assertEqual(events, [])
# non-idempotent
self.assertRaises(tkinter.TclError, f.unbind, event, funcid2)