Skip to content

[3.14] gh-155648: In IDLE tests, call unittest.main without exit arg (GH-156249) - #156252

Merged
terryjreedy merged 1 commit into
python:3.14from
miss-islington:backport-c20318b-3.14
Aug 23, 2026
Merged

[3.14] gh-155648: In IDLE tests, call unittest.main without exit arg (GH-156249)#156252
terryjreedy merged 1 commit into
python:3.14from
miss-islington:backport-c20318b-3.14

Conversation

@miss-islington

Copy link
Copy Markdown
Contributor

DD bug 73: In idlelib.idle_test, test_xyz.py files should end with

if name == 'main':
unittest.main(verbosity=2)

The default exit is True. This need not and should not be added.
5 files add the confusing equivalent exit=2 ("why the weird value?"),

4 files add exit=False. This is nonsensical when there is nothing more to run;
main will immediately exit anyway. When running a test file from an IDLE editor,
this argument has no visible effect. However, a Claude-based
bug finder claims that in other circumstances (such as a program running
the test in a shell), the good test may falsely fail. Even if this is
not true, it can only confuse a reader.

(The only place in idlelib for exit=False is in idlelib/abc.py files where the unittest
is followed by an htest. The default exit=True exits the process, skipping the htest.)

As part of editing the discussion of this in idle_test/htest.py, I clarified other things.
(cherry picked from commit c20318b)

Co-authored-by: Terry Jan Reedy tjreedy@udel.edu

…ythonGH-156249)

* pythongh-155648: In IDLE tests, call unittest.main without exit arg

DD bug 73: In idlelib.idle_test, test_xyz.py files should end with

if __name__ == '__main__':
    unittest.main(verbosity=2)

The default exit is True. This need not and should not be added.
5 files add the confusing equivalent exit=2 ("why the weird value?"),

4 files add exit=False. This is nonsensical when there is nothing more to run;
main will immediately exit anyway. When running a test file from an IDLE editor,
this argument has no visible effect. However, a Claude-based
bug finder claims that in other circumstances (such as a program running
the test in a shell), the good test may falsely fail. Even if this is
not true, it can only confuse a reader.

(The only place in idlelib for exit=False is in idlelib/abc.py files where the unittest
is followed by an htest. The default exit=True exits the process, skipping the htest.)

As part of editing the discussion of this in idle_test/htest.py, I clarified other things.
(cherry picked from commit c20318bf09e59946f805ace2bd15f70524009edc)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
@terryjreedy
terryjreedy enabled auto-merge (squash) August 23, 2026 05:40
@terryjreedy
terryjreedy merged commit 63bec1a into python:3.14 Aug 23, 2026
53 checks passed
@miss-islington
miss-islington deleted the backport-c20318b-3.14 branch August 23, 2026 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants