Skip to content

Increase test coverage for tkinter.simpledialog #144106

Closed

Description

@b9788213

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.

Linked PRs

Activity

  1. added a commit that references this issue on Jan 21, 2026
  2. serhiy-storchaka commented on Jan 23, 2026

    @serhiy-storchaka
    Member

    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.

  3. b9788213 commented on Jan 24, 2026

    @b9788213
    ContributorAuthor

    When i tried it something goes wrong in another test file

  4. serhiy-storchaka commented on Jun 27, 2026

    @serhiy-storchaka
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions