We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Logging in subtests is not displayed unless the parent test fails. Contrast with stdout is displayed for just the failing subtest.
Minimal example:
import logging def test_logging_in_subtests(subtests): logging.info("before") with subtests.test("sub1"): print("sub1 stdout") logging.info("sub1 logging") with subtests.test("sub2"): print("sub2 stdout") logging.info("sub2 logging") assert False
Running python3.8 -m pytest test_pytest.py --log-level=INFO stdout is output but not logs
python3.8 -m pytest test_pytest.py --log-level=INFO
... ------------------------------------------------------------------------------------------------- Captured stdout call -------------------------------------------------------------------------------------------------- sub2 stdout ================================================================================================ short test summary info ================================================================================================ SUBFAIL test_pytest.py::test_logging_in_subtests - assert False
If instead the parent test fails, logs are output from both failing & succeeding subtests. For example
import logging def test_logging_in_subtests(subtests): logging.info("before") with subtests.test("sub1"): print("sub1 stdout") logging.info("sub1 logging") with subtests.test("sub2"): print("sub2 stdout") logging.info("sub2 logging") assert False assert False
$ python3.8 -m pytest test_pytest.py --log-level=INFO now produces
$ python3.8 -m pytest test_pytest.py --log-level=INFO
------------------------------------------------------------------------------------------------- Captured stdout call -------------------------------------------------------------------------------------------------- sub2 stdout _______________________________________________________________________________________________ test_logging_in_subtests ________________________________________________________________________________________________ ...<stack trace> ... --------------------------------------------------------------------------------------------------- Captured log call --------------------------------------------------------------------------------------------------- INFO root:test_pytest.py:5 before INFO root:test_pytest.py:9 sub1 logging INFO root:test_pytest.py:13 sub2 logging ================================================================================================ short test summary info ================================================================================================ SUBFAIL test_pytest.py::test_logging_in_subtests - assert False FAILED test_pytest.py::test_logging_in_subtests - assert False
Can/should logging be displayed with a per subtest granularity similar to stdout?
The text was updated successfully, but these errors were encountered:
Log in subtests similar to stdout (#91)
9ec1dcb
Fix #87 --------- Co-authored-by: Bruno Oliveira <[email protected]>
Successfully merging a pull request may close this issue.
Logging in subtests is not displayed unless the parent test fails. Contrast with stdout is displayed for just the failing subtest.
Minimal example:
Running
python3.8 -m pytest test_pytest.py --log-level=INFO
stdout is output but not logsIf instead the parent test fails, logs are output from both failing & succeeding subtests. For example
$ python3.8 -m pytest test_pytest.py --log-level=INFO
now producesCan/should logging be displayed with a per subtest granularity similar to stdout?
The text was updated successfully, but these errors were encountered: