hbutils.testing.capture

Overview:

Utilities for capturing different kinds of results, which can be useful in testing.

capture_output

hbutils.testing.capture.capture_output() → AbstractContextManager[hbutils.testing.capture.output.OutputCaptureResult][source]
Overview:

Capture all the output to sys.stdout and sys.stderr in this with block.

Examples::
>>> from hbutils.testing import capture_output
>>> import sys
>>>
>>> with capture_output() as r:
...     print('this is stdout')
...     print('this is stderr', file=sys.stderr)
...
>>> r.stdout
'this is stdout\n'
>>> r.stderr
'this is stderr\n'

OutputCaptureResult

class hbutils.testing.capture.OutputCaptureResult[source]
__init__()[source]

Initialize self. See help(type(self)) for accurate signature.