Skip to content

--show-capture not working when --tb=line #13865

Description

@ttecles

I'm using pytest version 8.4.2 and it seems when I use --tb=line with --show-capture=stdout I don't get the output but when running with --tb=short I do get the output.

Actual behaviour

# tests/test_demo.py
def test_fail():
    print("WILL-SHOW")
    assert False

def test_no_print():
    assert False

Then I run pytest -q --tb=line --show-capture=stdout --disable-warnings tests/test_demo.py and I get the following output:

FF                                                                                [100%]
====================================== FAILURES =======================================
tests/test_demo.py:4: assert False
tests/test_demo.py:7: assert False
=============================== short test summary info ===============================
FAILED tests/test_demo.py::test_fail - assert False
FAILED tests/test_demo.py::test_no_print - assert False
2 failed, 1 warning in 0.02s

But if I run with pytest -q --tb=short --show-capture=stdout --disable-warnings tests/test_demo.py with the short traceback:

$ pytest -q --tb=short --show-capture=stdout --disable-warnings tests/test_demo.py 
FF                                                                                [100%]
====================================== FAILURES =======================================
____________ test_fail ____________
tests/test_demo.py:4: in test_fail
    assert False
E   assert False
------------------------------ Captured stdout call ---------------------------------
WILL-SHOW
__________ test_no_print __________
tests/test_demo.py:7: in test_no_print
    assert False
E   assert False
=============================== short test summary info ===============================
FAILED tests/test_demo.py::test_fail - assert False
FAILED tests/test_demo.py::test_no_print - assert False
2 failed, 1 warning in 0.32s

Now I can see the captured stdout call section.

Expected Behaviour

See the captured section no matter the traceback

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: capturerelated to the capture builtin plugintopic: tracebacksrelated to displaying and handling of tracebacks

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions