From fb936ef6740b349c3b618af9e76a4b08a5baf7de Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 29 Jun 2026 17:01:41 +0300 Subject: [PATCH] gh-69134: Wait until mapped in keyboard virtual-event tests 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 --- Lib/test/test_tkinter/test_widgets.py | 2 +- Lib/test/test_ttk/test_widgets.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_tkinter/test_widgets.py b/Lib/test/test_tkinter/test_widgets.py index 689acd1c321211..ab2fa45146de6e 100644 --- a/Lib/test/test_tkinter/test_widgets.py +++ b/Lib/test/test_tkinter/test_widgets.py @@ -1994,7 +1994,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('<>', 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 9379afb6aa47ee..b613572c6670d6 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('<>', lambda e: selects.append(self.tv.selection()))