Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Captured stdout for a subtest is not displayed properly #110

Open
yugokato opened this issue Oct 23, 2023 · 1 comment
Open

Captured stdout for a subtest is not displayed properly #110

yugokato opened this issue Oct 23, 2023 · 1 comment

Comments

@yugokato
Copy link

yugokato commented Oct 23, 2023

Captured stdout for a subtest is not displayed when the --capture option value is fd or sys. It is displayed as expected when the value is tee-sys.
This causes pytest-html plugin not to be able to display them in a report either. (pytest-dev/pytest-html#750)

Minimum code to reproduce:

def test_something(subtests):
    print("main test")

    with subtests.test("subtest"):
        print("sub test")

Logs:

  • --capture=fd (or sys)
$ pytest -rA 
============================================================ test session starts =============================================================
platform darwin -- Python 3.9.18, pytest-7.4.2, pluggy-1.3.0
rootdir: /Users/yugo/Desktop/test
plugins: subtests-0.11.0
collected 1 item                                                                                                                             

test_something.py ,.                                                                                                                   [100%]

=================================================================== PASSES ===================================================================
_______________________________________________________________ test_something _______________________________________________________________
------------------------------------------------------------ Captured stdout call ------------------------------------------------------------
main test
========================================================== short test summary info ===========================================================
PASSED test_something.py::test_something
==================================================== 1 passed, 1 subtests passed in 0.02s ====================================================
  • --capture=tee-sys
$ pytest -rA --capture=tee-sys
============================================================ test session starts =============================================================
platform darwin -- Python 3.9.18, pytest-7.4.2, pluggy-1.3.0
rootdir: /Users/yugo/Desktop/test
plugins: subtests-0.11.0
collected 1 item                                                                                                                             

test_something.py main test
sub test
,.                                                                                                                   [100%]

=================================================================== PASSES ===================================================================
_______________________________________________________________ test_something _______________________________________________________________
------------------------------------------------------------ Captured stdout call ------------------------------------------------------------
main test
sub test
========================================================== short test summary info ===========================================================
PASSED test_something.py::test_something
==================================================== 1 passed, 1 subtests passed in 0.02s ====================================================
$ pip freeze
attrs==23.1.0
exceptiongroup==1.1.3
iniconfig==2.0.0
packaging==23.2
pluggy==1.3.0
pytest==7.4.2
pytest-subtests==0.11.0
tomli==2.0.1
@rhoban13
Copy link
Contributor

My suspicion here is this has something to do with the -rA flag. This plugin captures output here so I suspect we'd need to add something which looks at the -rA flag similar to here in terminal.py.

Although I'm not clear how that impacts the html report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants