Skip to content

Captured stdout in a subtest (pytest-subtests) is not displayed properly #750

@yugokato

Description

@yugokato

Captured stdout in a subtest is not displayed as expected. Tested with v3.2.0 and v4.0.2 - both have the issue in a different way. Also the issue behavior changes depending on the --capture option value. I tried fd (the default value) and tee-sys. Only v3.2.0 with --capture tee-sys seems to work as expected.

  • Test code to reproduce:
def test_something(subtests):
    print("main test")

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

    • v3.2.0

      1. command: pytest --html fd_3.2.0.html
        -> Captured stdout from the subtest is missing
      2. command: pytest --html tee-sys_3.2.0.html --capture tee-sys
        -> Looks good
    • v4.0.2

      1. command: pytest --html fd_4.0.2.html
        -> main test and subtest are displayed as separate tests. One has captured stdout from the main test, the other has captured stdout from the subtest
      2. command: pytest --html tee-sys_4.0.2.html --capture tee-sys
        -> main test and subtest are displayed as separate tests. One has no captured stdout, the other has captured stdout from both main test and subtest

fd_3 2 0
tee-sys_3 2 0
fd_4 0 2
tee-sys_4 0 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions