Skip to content

Commit be4eebb

Browse files
gh-69134: Wait until mapped in keyboard virtual-event tests (GH-152599)
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>
1 parent 1b0c05f commit be4eebb

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

Lib/test/test_tkinter/test_widgets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1994,7 +1994,7 @@ def test_selection_event(self):
19941994
lb = self.create(selectmode='browse', exportselection=False)
19951995
lb.insert(0, *('el%d' % i for i in range(5)))
19961996
lb.pack()
1997-
lb.update()
1997+
self.require_mapped(lb)
19981998
events = []
19991999
lb.bind('<<ListboxSelect>>', lambda e: events.append(lb.curselection()))
20002000
lb.focus_force()

Lib/test/test_ttk/test_widgets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1977,7 +1977,7 @@ def test_virtual_events(self):
19771977
self.tv.insert(parent, 'end')
19781978
item2 = self.tv.insert('', 'end')
19791979
self.tv.pack()
1980-
self.tv.update()
1980+
self.require_mapped(self.tv)
19811981
selects, opens, closes = [], [], []
19821982
self.tv.bind('<<TreeviewSelect>>',
19831983
lambda e: selects.append(self.tv.selection()))

0 commit comments

Comments
 (0)