]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.11] gh-103186: Fix or catch 'extra' stderr output from unittests (#103196) (#106606)
authorTerry Jan Reedy <tjreedy@udel.edu>
Mon, 10 Jul 2023 21:13:26 +0000 (17:13 -0400)
committerGitHub <noreply@github.com>
Mon, 10 Jul 2023 21:13:26 +0000 (21:13 +0000)
commit563829df559332eaa169c5cd84ce87e4f962dfaa
tree0b4780e709c18ad79d311f9b22118e973c04d178
parentdd046973379cdc5cab47d3ddc878521b175f10c8
[3.11] gh-103186: Fix or catch 'extra' stderr output from unittests (#103196) (#106606)

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.
---------

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
(cherry picked from commit 9d582250d8fde240b8e7299b74ba888c574f74a3)
Lib/test/test_cmd_line_script.py
Lib/test/test_warnings/__init__.py