diff options
| author | Ijtaba Hussain <ijtabahussain@live.com> | 2023-07-10 20:29:03 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-10 20:29:03 (GMT) |
| commit | 9d582250d8fde240b8e7299b74ba888c574f74a3 (patch) | |
| tree | c0cc6bbbf9fcc97e5279c2ff39fa7d3680db053f /Lib/test/test_cmd_line_script.py | |
| parent | a840806d338805fe74a9de01081d30da7605a29f (diff) | |
| download | cpython-9d582250d8fde240b8e7299b74ba888c574f74a3.zip cpython-9d582250d8fde240b8e7299b74ba888c574f74a3.tar.gz cpython-9d582250d8fde240b8e7299b74ba888c574f74a3.tar.bz2 | |
gh-103186: Fix or catch 'extra' stderr output from unittests (#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.
---------
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Diffstat (limited to 'Lib/test/test_cmd_line_script.py')
| -rw-r--r-- | Lib/test/test_cmd_line_script.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py index 8bf2993..1b58882 100644 --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -777,7 +777,7 @@ class CmdLineTest(unittest.TestCase): with os_helper.temp_dir() as work_dir: script_name = _make_test_script(work_dir, 'script.py', script) with open(script_name, "r") as fp: - p = spawn_python(f"/dev/fd/{fp.fileno()}", close_fds=False, pass_fds=(0,1,2,fp.fileno())) + p = spawn_python(f"/dev/fd/{fp.fileno()}", close_fds=True, pass_fds=(0,1,2,fp.fileno())) out, err = p.communicate() self.assertEqual(out, b"12345678912345678912345\n") |
