https://github.com/python/cpython/commit/05cf0072a71790c9229c1fb89914b1a46abccc86
commit: 05cf0072a71790c9229c1fb89914b1a46abccc86
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-06-29T16:00:20Z
summary:

[3.15] gh-69134: Wait until mapped in keyboard virtual-event tests (GH-152599) 
(GH-152605)

test_virtual_events and test_selection_event generate key events after
focus_force().  On Windows these are only delivered once the toplevel is
mapped, so they could be dropped and the test fail.  Wait until the
widget is mapped, as the other GUI tests already do.
(cherry picked from commit be4eebb8386d07f360dd835a0ecb4a1eb6385736)

Co-authored-by: Serhiy Storchaka <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>

files:
M Lib/test/test_tkinter/test_widgets.py
M Lib/test/test_ttk/test_widgets.py

diff --git a/Lib/test/test_tkinter/test_widgets.py 
b/Lib/test/test_tkinter/test_widgets.py
index f5481e7712dad4..efd9beed71a88b 100644
--- a/Lib/test/test_tkinter/test_widgets.py
+++ b/Lib/test/test_tkinter/test_widgets.py
@@ -1934,7 +1934,7 @@ def test_selection_event(self):
         lb = self.create(selectmode='browse', exportselection=False)
         lb.insert(0, *('el%d' % i for i in range(5)))
         lb.pack()
-        lb.update()
+        self.require_mapped(lb)
         events = []
         lb.bind('<<ListboxSelect>>', lambda e: 
events.append(lb.curselection()))
         lb.focus_force()
diff --git a/Lib/test/test_ttk/test_widgets.py 
b/Lib/test/test_ttk/test_widgets.py
index 5c50fb659d47de..5b1000b699e4b0 100644
--- a/Lib/test/test_ttk/test_widgets.py
+++ b/Lib/test/test_ttk/test_widgets.py
@@ -1977,7 +1977,7 @@ def test_virtual_events(self):
         self.tv.insert(parent, 'end')
         item2 = self.tv.insert('', 'end')
         self.tv.pack()
-        self.tv.update()
+        self.require_mapped(self.tv)
         selects, opens, closes = [], [], []
         self.tv.bind('<<TreeviewSelect>>',
                      lambda e: selects.append(self.tv.selection()))

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to