summaryrefslogtreecommitdiffstats
path: root/Lib/test/support
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2021-10-12 23:52:22 (GMT)
committerGitHub <noreply@github.com>2021-10-12 23:52:22 (GMT)
commitdbe213de7ef28712bbfdb9d94a33abb9c33ef0c2 (patch)
tree3c94ff3ceddfb9d0ef52c18cdd18b735c31fac6c /Lib/test/support
parent2d21612f0dd84bf6d0ce35bcfcc9f0e1a41c202d (diff)
downloadcpython-dbe213de7ef28712bbfdb9d94a33abb9c33ef0c2.zip
cpython-dbe213de7ef28712bbfdb9d94a33abb9c33ef0c2.tar.gz
cpython-dbe213de7ef28712bbfdb9d94a33abb9c33ef0c2.tar.bz2
bpo-45410: Enhance libregrtest -W/--verbose3 option (GH-28908)
libregrtest -W/--verbose3 now also replace sys.__stdout__, sys.__stderr__, and stdout and stderr file descriptors (fd 1 and fd 2). support.print_warning() messages are now logged in the expected order. The "./python -m test test_eintr -W" command no longer logs into stdout if the test pass.
Diffstat (limited to 'Lib/test/support')
-rw-r--r--Lib/test/support/__init__.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index 0bbe813..45801dc 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -1179,8 +1179,10 @@ def print_warning(msg):
flush_std_streams()
# bpo-39983: Print into sys.__stderr__ to display the warning even
# when sys.stderr is captured temporarily by a test
+ stream = sys.__stderr__
for line in msg.splitlines():
- print(f"Warning -- {line}", file=sys.__stderr__, flush=True)
+ print(f"Warning -- {line}", file=stream)
+ stream.flush()
# Flag used by saved_test_environment of test.libregrtest.save_env,