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 commented on 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 commented on Jan 24, 2026
When i tried it something goes wrong in another test file
serhiy-storchaka commented on Jun 27, 2026
Comprehensive tests for tkinter.simpledialog were since added under gh-151678:
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.