r"""Enable simultaneous text capturing and pass-through of writes to ``sys.stdout`` and ``sys.stderr`` as defined by ``--capture=``. The captured output is made available via ``capteesys.readouterr()`` method calls, which return a ``(out, err)`` namedtuple. ``out`` and ``err`` will
(request: SubRequest)
| 1033 | |
| 1034 | @fixture |
| 1035 | def capteesys(request: SubRequest) -> Generator[CaptureFixture[str]]: |
| 1036 | rclass="st">"""Enable simultaneous text capturing and pass-through of writes |
| 1037 | to ``sys.stdout`` and ``sys.stderr`` as defined by ``--capture=``. |
| 1038 | |
| 1039 | |
| 1040 | The captured output is made available via ``capteesys.readouterr()`` method |
| 1041 | calls, which return a ``(out, err)`` namedtuple. |
| 1042 | ``out`` and ``err`` will be ``text`` objects. |
| 1043 | |
| 1044 | The output is also passed-through, allowing it to be class="st">"live-printed", |
| 1045 | reported, or both as defined by ``--capture=``. |
| 1046 | |
| 1047 | Returns an instance of :class:`CaptureFixture[str] <pytest.CaptureFixture>`. |
| 1048 | |
| 1049 | Example: |
| 1050 | |
| 1051 | .. code-block:: python |
| 1052 | |
| 1053 | def test_output(capteesys): |
| 1054 | print(class="st">"hello") |
| 1055 | captured = capteesys.readouterr() |
| 1056 | assert captured.out == class="st">"hello\n" |
| 1057 | class="st">""" |
| 1058 | capman: CaptureManager = request.config.pluginmanager.getplugin(class="st">"capturemanager") |
| 1059 | capture_fixture = CaptureFixture( |
| 1060 | SysCapture, request, config=dict(tee=True), _ispytest=True |
| 1061 | ) |
| 1062 | capman.set_fixture(capture_fixture) |
| 1063 | capture_fixture._start() |
| 1064 | yield capture_fixture |
| 1065 | capture_fixture.close() |
| 1066 | capman.unset_fixture() |
| 1067 | |
| 1068 | |
| 1069 | @fixture |
nothing calls this directly
no test coverage detected