@@ -197,9 +197,9 @@ def _ensure_only_one_capture_fixture(request, name):
197197
198198@pytest .fixture
199199def capsys (request ):
200- """Enable capturing of writes to sys.stdout/ sys.stderr and make
200+ """Enable capturing of writes to `` sys.stdout`` and `` sys.stderr`` and make
201201 captured output available via ``capsys.readouterr()`` method calls
202- which return a ``(out, err)`` tuple . ``out`` and ``err`` will be ``text``
202+ which return a ``(out, err)`` namedtuple . ``out`` and ``err`` will be ``text``
203203 objects.
204204 """
205205 _ensure_only_one_capture_fixture (request , 'capsys' )
@@ -209,7 +209,7 @@ def capsys(request):
209209
210210@pytest .fixture
211211def capsysbinary (request ):
212- """Enable capturing of writes to sys.stdout/ sys.stderr and make
212+ """Enable capturing of writes to `` sys.stdout`` and `` sys.stderr`` and make
213213 captured output available via ``capsys.readouterr()`` method calls
214214 which return a ``(out, err)`` tuple. ``out`` and ``err`` will be ``bytes``
215215 objects.
@@ -225,7 +225,7 @@ def capsysbinary(request):
225225
226226@pytest .fixture
227227def capfd (request ):
228- """Enable capturing of writes to file descriptors 1 and 2 and make
228+ """Enable capturing of writes to file descriptors ``1`` and ``2`` and make
229229 captured output available via ``capfd.readouterr()`` method calls
230230 which return a ``(out, err)`` tuple. ``out`` and ``err`` will be ``text``
231231 objects.
@@ -272,6 +272,10 @@ def _install_capture_fixture_on_item(request, capture_class):
272272
273273
274274class CaptureFixture (object ):
275+ """
276+ Object returned by :py:func:`capsys`, :py:func:`capsysbinary`, :py:func:`capfd` and :py:func:`capfdbinary`
277+ fixtures.
278+ """
275279 def __init__ (self , captureclass , request ):
276280 self .captureclass = captureclass
277281 self .request = request
@@ -288,13 +292,18 @@ def close(self):
288292 cap .stop_capturing ()
289293
290294 def readouterr (self ):
295+ """Read and return the captured output so far, resetting the internal buffer.
296+
297+ :return: captured content as a namedtuple with ``out`` and ``err`` string attributes
298+ """
291299 try :
292300 return self ._capture .readouterr ()
293301 except AttributeError :
294302 return self ._outerr
295303
296304 @contextlib .contextmanager
297305 def disabled (self ):
306+ """Temporarily disables capture while inside the 'with' block."""
298307 self ._capture .suspend_capturing ()
299308 capmanager = self .request .config .pluginmanager .getplugin ('capturemanager' )
300309 capmanager .suspend_global_capture (item = None , in_ = False )
0 commit comments