File tree 1 file changed +11
-7
lines changed
1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -92,14 +92,14 @@ an example test function that performs some output related checks:
92
92
.. code-block :: python
93
93
94
94
def test_myoutput (capsys ): # or use "capfd" for fd-level
95
- print (" hello" )
95
+ print (" hello" )
96
96
sys.stderr.write(" world\n " )
97
- out, err = capsys.readouterr()
98
- assert out == " hello\n "
99
- assert err == " world\n "
100
- print (" next" )
101
- out, err = capsys.readouterr()
102
- assert out == " next\n "
97
+ captured = capsys.readouterr()
98
+ assert captured. out == " hello\n "
99
+ assert captured. err == " world\n "
100
+ print (" next" )
101
+ captured = capsys.readouterr()
102
+ assert captured. out == " next\n "
103
103
104
104
The ``readouterr() `` call snapshots the output so far -
105
105
and capturing will be continued. After the test
@@ -117,6 +117,10 @@ system level output streams (FD1 and FD2).
117
117
118
118
.. versionadded :: 3.3
119
119
120
+ The return value from ``readouterr `` changed to a ``namedtuple `` with two attributes, ``out `` and ``err ``.
121
+
122
+ .. versionadded :: 3.3
123
+
120
124
If the code under test writes non-textual data, you can capture this using
121
125
the ``capsysbinary `` fixture which instead returns ``bytes `` from
122
126
the ``readouterr `` method. The ``capfsysbinary `` fixture is currently only
You can’t perform that action at this time.
0 commit comments