diff options
author | Victor Stinner <vstinner@python.org> | 2021-10-13 12:08:18 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-13 12:08:18 (GMT) |
commit | 773330773968f211c77abc7b5b525faa7b3c35a2 (patch) | |
tree | 227525b1ec3989adde6ab6e630b5e4f87471d5a1 /Lib/test/test_support.py | |
parent | 380c44087505d0d560f97e325028f27393551164 (diff) | |
download | cpython-773330773968f211c77abc7b5b525faa7b3c35a2.zip cpython-773330773968f211c77abc7b5b525faa7b3c35a2.tar.gz cpython-773330773968f211c77abc7b5b525faa7b3c35a2.tar.bz2 |
bpo-45410: regrtest -W leaves stdout/err FD unchanged (GH-28915)
support.print_warning() now stores the original value of
sys.__stderr__ and uses it to log warnings. libregrtest uses the same
stream to log unraisable exceptions and uncaught threading
exceptions.
Partially revert commit dbe213de7ef28712bbfdb9d94a33abb9c33ef0c2:
libregrtest no longer replaces sys.__stdout__, sys.__stderr__, and
stdout and stderr file descriptors.
Remove also a few unused imports in libregrtest.
Diffstat (limited to 'Lib/test/test_support.py')
-rw-r--r-- | Lib/test/test_support.py | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index 8b55352..d5a1d44 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -469,12 +469,8 @@ class TestSupport(unittest.TestCase): if time.monotonic() > deadline: self.fail("timeout") - old_stderr = sys.__stderr__ - try: - sys.__stderr__ = stderr + with support.swap_attr(support.print_warning, 'orig_stderr', stderr): support.reap_children() - finally: - sys.__stderr__ = old_stderr # Use environment_altered to check if reap_children() found # the child process @@ -674,14 +670,8 @@ class TestSupport(unittest.TestCase): def check_print_warning(self, msg, expected): stderr = io.StringIO() - - old_stderr = sys.__stderr__ - try: - sys.__stderr__ = stderr + with support.swap_attr(support.print_warning, 'orig_stderr', stderr): support.print_warning(msg) - finally: - sys.__stderr__ = old_stderr - self.assertEqual(stderr.getvalue(), expected) def test_print_warning(self): |