Skip to content

gh-154357: Fix race condition in test_simpledialog by explicitly setting focus to entry#154368

Closed
arshalaromal wants to merge 3 commits into
python:mainfrom
arshalaromal:fix-tkinter-154357
Closed

gh-154357: Fix race condition in test_simpledialog by explicitly setting focus to entry#154368
arshalaromal wants to merge 3 commits into
python:mainfrom
arshalaromal:fix-tkinter-154357

Conversation

@arshalaromal

Copy link
Copy Markdown
Contributor

Fixes gh-154357.

Summary of Changes

In Lib/test/test_tkinter/test_simpledialog.py, enter() was generating <Return> events directly on the top-level dialog d without ensuring d.entry had active focus. On headless or slow CI runners, this caused key events to get dropped, leaving d.result as None and leading to flaky failures in test_boundary_values_accepted.

This PR fixes the race condition by:

  1. Explicitly focusing d.entry via d.entry.focus_set().
  2. Flushing pending idle events with d.update_idletasks() before generating the key event directly on d.entry.

Cc @serhiy-storchaka

@bedevere-app bedevere-app Bot added the tests Tests in the Lib/test dir label Jul 21, 2026
@serhiy-storchaka

Copy link
Copy Markdown
Member

Sorry, but I am already working on more complete fix #154370.

@arshalaromal
arshalaromal deleted the fix-tkinter-154357 branch July 22, 2026 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tkinter: test_boundary_values_accepted fails

2 participants