Skip to content

Commit 76301d0

Browse files
gh-154357: Tolerate additional focus events in test_focus
All focus events seen by bindings are generated by Tk itself: one in focus_force(), and one more when the real X focus event arrives and the window manager had taken the focus away in between. Only the first event, generated by focus_force(), is checked.
1 parent c2748c6 commit 76301d0

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Lib/test/test_tkinter/test_misc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,9 @@ def test_focus(self):
13731373

13741374
f.focus_force()
13751375
self.root.update()
1376-
self.assertEqual(len(events), 1, events)
1376+
# The window manager can take the focus away and give it back,
1377+
# which makes Tk generate additional focus events.
1378+
self.assertGreaterEqual(len(events), 1, events)
13771379
e = events[0]
13781380
self.assertIs(e.type, tkinter.EventType.FocusIn)
13791381
self.assertIs(e.widget, f)

0 commit comments

Comments
 (0)