]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-69134: Wait until mapped in keyboard virtual-event tests (GH-152599)
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 29 Jun 2026 15:30:23 +0000 (18:30 +0300)
committerGitHub <noreply@github.com>
Mon, 29 Jun 2026 15:30:23 +0000 (15:30 +0000)
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.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Lib/test/test_tkinter/test_widgets.py
Lib/test/test_ttk/test_widgets.py

index 689acd1c321211e13b1f4bad81795b782a7600fc..ab2fa45146de6ea6650152d6fa6c9f7d5989466d 100644 (file)
@@ -1994,7 +1994,7 @@ class ListboxTest(AbstractWidgetTest, unittest.TestCase):
         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()
index 9379afb6aa47eef996ada4fc1c2a95f3f5453c27..b613572c6670d6b34f6279cb86dd36ccaf3b201f 100644 (file)
@@ -1977,7 +1977,7 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
         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()))