r"""Enable text capturing of writes to file descriptors ``1`` and ``2``. The captured output is made available via ``capfd.readouterr()`` method calls, which return a ``(out, err)`` namedtuple. ``out`` and ``err`` will be ``text`` objects. Returns an instance of :class:`CaptureFixt
(request: SubRequest)
| 1096 | |
| 1097 | @fixture |
| 1098 | def capfd(request: SubRequest) -> Generator[CaptureFixture[str]]: |
| 1099 | r"""Enable text capturing of writes to file descriptors ``1`` and ``2``. |
| 1100 | |
| 1101 | The captured output is made available via ``capfd.readouterr()`` method |
| 1102 | calls, which return a ``(out, err)`` namedtuple. |
| 1103 | ``out`` and ``err`` will be ``text`` objects. |
| 1104 | |
| 1105 | Returns an instance of :class:`CaptureFixture[str] <pytest.CaptureFixture>`. |
| 1106 | |
| 1107 | Example: |
| 1108 | |
| 1109 | .. code-block:: python |
| 1110 | |
| 1111 | def test_system_echo(capfd): |
| 1112 | os.system('echo "hello"') |
| 1113 | captured = capfd.readouterr() |
| 1114 | assert captured.out == "hello\n" |
| 1115 | """ |
| 1116 | capman: CaptureManager = request.config.pluginmanager.getplugin("capturemanager") |
| 1117 | capture_fixture = CaptureFixture(FDCapture, request, _ispytest=True) |
| 1118 | capman.set_fixture(capture_fixture) |
| 1119 | capture_fixture._start() |
| 1120 | yield capture_fixture |
| 1121 | capture_fixture.close() |
| 1122 | capman.unset_fixture() |
| 1123 | |
| 1124 | |
| 1125 | @fixture |
nothing calls this directly
no test coverage detected