From 9ac7cd886b4c3a9dd25caf72007456e6140541b4 Mon Sep 17 00:00:00 2001 From: Hugohong258 <282228220+Hugohong258@users.noreply.github.com> Date: Sun, 13 Sep 2026 15:32:43 +0800 Subject: [PATCH 1/3] docs: import sys in the captured output example Co-authored-by: OpenAI Codex --- doc/en/how-to/capture-stdout-stderr.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/en/how-to/capture-stdout-stderr.rst b/doc/en/how-to/capture-stdout-stderr.rst index 5de89bc0e3f..bc5c03d4ca9 100644 --- a/doc/en/how-to/capture-stdout-stderr.rst +++ b/doc/en/how-to/capture-stdout-stderr.rst @@ -121,6 +121,9 @@ Here is an example test function that performs some output related checks: .. code-block:: python + import sys + + def test_myoutput(capsys): # or use "capfd" for fd-level print("hello") sys.stderr.write("world\n") From bf13446ea10260ea67f1351e1a977a579b16ebfa Mon Sep 17 00:00:00 2001 From: Hugohong258 <282228220+Hugohong258@users.noreply.github.com> Date: Sun, 13 Sep 2026 22:33:51 +0800 Subject: [PATCH 2/3] docs: validate capture example with regendoc Co-authored-by: OpenAI Codex --- doc/en/how-to/capture-stdout-stderr.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/en/how-to/capture-stdout-stderr.rst b/doc/en/how-to/capture-stdout-stderr.rst index bc5c03d4ca9..8b6198176fd 100644 --- a/doc/en/how-to/capture-stdout-stderr.rst +++ b/doc/en/how-to/capture-stdout-stderr.rst @@ -121,6 +121,7 @@ Here is an example test function that performs some output related checks: .. code-block:: python + # content of test_output.py import sys @@ -134,6 +135,12 @@ Here is an example test function that performs some output related checks: captured = capsys.readouterr() assert captured.out == "next\n" +.. code-block:: pytest + + $ pytest -q test_output.py + . [100%] + 1 passed in 0.12s + The ``readouterr()`` call snapshots the output so far - and capturing will be continued. After the test function finishes the original streams will From 342ec784e36a021a033ae5cb1dd3294da017a9a7 Mon Sep 17 00:00:00 2001 From: Hugohong258 <282228220+Hugohong258@users.noreply.github.com> Date: Mon, 14 Sep 2026 03:42:11 +0800 Subject: [PATCH 3/3] Add Hugohong258 to AUTHORS Co-authored-by: OpenAI Codex --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index daa6a471eb9..1ddfff20926 100644 --- a/AUTHORS +++ b/AUTHORS @@ -211,6 +211,7 @@ Henk-Jaap Wagenaar Henry Schreiner Holger Kohr Hugo van Kemenade +Hugohong258 Hui Wang (coldnight) Ian Bicking Ian Lesperance