You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Increase test coverage for tkinter.simpledialog #144106
The tkinter.simpledialog module currently has low test coverage (%46). test_simpledialog only tests askinteger function. I tried askfloat, it works well but askstring throws an unrelated exception.
It does not look like these tests add much value. There is already a manual test in Lib/tkinter/simpledialog.py. For automatic tests, we need to test the the dialogs are appeared at right position, that entering data in the entry field and pressing the buttons work as expected. This may be possible, but this is not easy.
test_simpledialog.py is now 44 tests covering askinteger, askfloat and askstring with real entry input and accept/cancel, validation and min/max boundaries, plus the Dialog/SimpleDialog appearance, buttons, accelerators and keyboard traversal. The query dialogs are driven by mocking Dialog.wait_window, so the modal dialog stays alive and can be exercised with generated events — the approach mentioned above. (The askstring exception you saw was test-isolation from a leaked default root, which the test setup now avoids.)
This covers what was requested, so I'm closing as completed. PR #144107 is superseded by the above and can be closed too. Thanks for raising it.
Activity
pythongh-144106 Add tests to the tkinter
serhiy-storchaka commentedon Jan 23, 2026
What exception?
It does not look like these tests add much value. There is already a manual test in
Lib/tkinter/simpledialog.py. For automatic tests, we need to test the the dialogs are appeared at right position, that entering data in the entry field and pressing the buttons work as expected. This may be possible, but this is not easy.b9788213 commentedon Jan 24, 2026
When i tried it something goes wrong in another test file
serhiy-storchaka commentedon Jun 27, 2026
Comprehensive tests for
tkinter.simpledialogwere since added under gh-151678:test_simpledialog.pyis now 44 tests coveringaskinteger,askfloatandaskstringwith real entry input and accept/cancel, validation and min/max boundaries, plus theDialog/SimpleDialogappearance, buttons, accelerators and keyboard traversal. The query dialogs are driven by mockingDialog.wait_window, so the modal dialog stays alive and can be exercised with generated events — the approach mentioned above. (Theaskstringexception you saw was test-isolation from a leaked default root, which the test setup now avoids.)This covers what was requested, so I'm closing as completed. PR #144107 is superseded by the above and can be closed too. Thanks for raising it.