@@ -106,9 +106,10 @@ of the failing function and hide the other one:
106106 Accessing captured output from a test function
107107---------------------------------------------------
108108
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:
112113
113114.. code-block :: python
114115
@@ -125,40 +126,27 @@ an example test function that performs some output related checks:
125126 The ``readouterr() `` call snapshots the output so far -
126127and capturing will be continued. After the test
127128function finishes the original streams will
128- be restored. Using `` capsys ` ` this way frees your
129+ be restored. Using :fixture: ` capsys ` this way frees your
129130test from having to care about setting/resetting
130131output streams and also interacts well with pytest's
131132own per-test capturing.
132133
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-
141134The return value from ``readouterr `` changed to a ``namedtuple `` with two attributes, ``out `` and ``err ``.
142135
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
147138the ``readouterr `` method.
148139
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.
149146
150147
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
162150as a context manager, disabling capture inside the ``with `` block:
163151
164152.. code-block :: python
0 commit comments