Skip to content

capture: keep all output for "Captured stdout call" etc #3448

@blueyed

Description

@blueyed

It looks like using capfd.readouterr() in a test also resets what pytest displays in case of failed tests.

For this I think it would be useful to keep the output in total.

capfd = <_pytest.capture.CaptureFixture object at 0x7fc6da051908>

    def test_capfd(capfd):
        print('stdout')
        print(2, capfd.readouterr())
        print(3)
>       assert 0
E       assert 0

tests/test_capfd.py:11: AssertionError
----------------------------------- Captured stdout call ------------------------------------
2 CaptureResult(out='stdout\n', err='')
3

Here the stdout is missing.

pytest master (08aed1a).

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: capturerelated to the capture builtin plugintype: enhancementnew feature or API change, should be merged into features branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions