bpo-39983: Add test.support.print_warning() (GH-19683)
Log "Warning -- ..." test warnings into sys.__stderr__ rather than
sys.stderr, to ensure to display them even if sys.stderr is captured.
test.libregrtest.utils.print_warning() now calls
test.support.print_warning().
diff --git a/Doc/library/test.rst b/Doc/library/test.rst
index c33465d..0573c27 100644
--- a/Doc/library/test.rst
+++ b/Doc/library/test.rst
@@ -825,6 +825,15 @@
target of the "as" clause, if there is one.
+.. function:: print_warning(msg)
+
+ Print a warning into :data:`sys.__stderr__`. Format the message as:
+ ``f"Warning -- {msg}"``. If *msg* is made of multiple lines, add
+ ``"Warning -- "`` prefix to each line.
+
+ .. versionadded:: 3.9
+
+
.. function:: wait_process(pid, *, exitcode, timeout=None)
Wait until process *pid* completes and check that the process exit code is