@@ -106,9 +106,10 @@ of the failing function and hide the other one:
106
106
Accessing captured output from a test function
107
107
---------------------------------------------------
108
108
109
- The ``capsys ``, ``capsysbinary ``, ``capfd ``, and ``capfdbinary `` fixtures
110
- allow access to stdout/stderr output created during test execution. Here is
111
- an example test function that performs some output related checks:
109
+ The :fixture: `capsys `, :fixture: `capsysbinary `, :fixture: `capfd `, and :fixture: `capfdbinary ` fixtures
110
+ allow access to ``stdout ``/``stderr `` output created during test execution.
111
+
112
+ Here is an example test function that performs some output related checks:
112
113
113
114
.. code-block :: python
114
115
@@ -125,40 +126,27 @@ an example test function that performs some output related checks:
125
126
The ``readouterr() `` call snapshots the output so far -
126
127
and capturing will be continued. After the test
127
128
function finishes the original streams will
128
- be restored. Using `` capsys ` ` this way frees your
129
+ be restored. Using :fixture: ` capsys ` this way frees your
129
130
test from having to care about setting/resetting
130
131
output streams and also interacts well with pytest's
131
132
own per-test capturing.
132
133
133
- If you want to capture on filedescriptor level you can use
134
- the ``capfd `` fixture which offers the exact
135
- same interface but allows to also capture output from
136
- libraries or subprocesses that directly write to operating
137
- system level output streams (FD1 and FD2).
138
-
139
-
140
-
141
134
The return value from ``readouterr `` changed to a ``namedtuple `` with two attributes, ``out `` and ``err ``.
142
135
143
-
144
-
145
- If the code under test writes non-textual data, you can capture this using
146
- the ``capsysbinary `` fixture which instead returns ``bytes `` from
136
+ If the code under test writes non-textual data (``bytes ``), you can capture this using
137
+ the :fixture: `capsysbinary ` fixture which instead returns ``bytes `` from
147
138
the ``readouterr `` method.
148
139
140
+ If you want to capture at the file descriptor level you can use
141
+ the :fixture: `capfd ` fixture which offers the exact
142
+ same interface but allows to also capture output from
143
+ libraries or subprocesses that directly write to operating
144
+ system level output streams (FD1 and FD2). Similarly to :fixture: `capsysbinary `, :fixture: `capfdbinary ` can be
145
+ used to capture ``bytes `` at the file descriptor level.
149
146
150
147
151
-
152
- If the code under test writes non-textual data, you can capture this using
153
- the ``capfdbinary `` fixture which instead returns ``bytes `` from
154
- the ``readouterr `` method. The ``capfdbinary `` fixture operates on the
155
- filedescriptor level.
156
-
157
-
158
-
159
-
160
- To temporarily disable capture within a test, both ``capsys ``
161
- and ``capfd `` have a ``disabled() `` method that can be used
148
+ To temporarily disable capture within a test, the capture fixtures
149
+ have a ``disabled() `` method that can be used
162
150
as a context manager, disabling capture inside the ``with `` block:
163
151
164
152
.. code-block :: python
0 commit comments