Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.12] gh-103186: Fix or catch 'extra' stderr output from unittests (GH-103196) #106605

Merged
merged 1 commit into from
Jul 10, 2023

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jul 10, 2023

Reduce test noise by fixing or catching and testing stderr messages from individual tests.

test_cmd_line_script.test_script_as_dev_fd calls spawn_python and hence subprocess.Popen with incompatible arguments. On POSIX, pass_fds forces close_fds to be True (subprocess.py line 848). Correct the call.

test_uuid.test_cli_namespace_required_for_uuid3: when the namespace is omitted, uuid.main calls argparse.Argument_Parser.error, which prints to stderr before calling sys.exit, which raises SystemExit. Unittest assertRaises catches the exception but not the previous output. Catch the output and test it.

test_warnings.test_catchwarnings_with_simplefilter_error similarly prints before raising. Catch the output and test it.

(cherry picked from commit 9d58225)

Co-authored-by: Ijtaba Hussain [email protected]
Co-authored-by: Oleg Iarygin [email protected]

…ythonGH-103196)

Reduce test noise by fixing or catching and testing stderr messages from individual tests.

test_cmd_line_script.test_script_as_dev_fd calls spawn_python and hence subprocess.Popen with incompatible arguments. On POSIX, pass_fds forces close_fds to be True (subprocess.py line 848). Correct the call.

test_uuid.test_cli_namespace_required_for_uuid3: when the namespace is omitted, uuid.main calls argparse.Argument_Parser.error, which prints to stderr before calling sys.exit, which raises SystemExit. Unittest assertRaises catches the exception but not the previous output. Catch the output and test it.

test_warnings.test_catchwarnings_with_simplefilter_error similarly prints before raising. Catch the output and test it.
---------

(cherry picked from commit 9d58225)

Co-authored-by: Ijtaba Hussain <[email protected]>
Co-authored-by: Oleg Iarygin <[email protected]>
@terryjreedy terryjreedy enabled auto-merge (squash) July 10, 2023 20:45
@terryjreedy terryjreedy merged commit 68ca190 into python:3.12 Jul 10, 2023
16 checks passed
@miss-islington miss-islington deleted the backport-9d58225-3.12 branch July 10, 2023 21:03
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.

4 participants