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

Log in subtests similar to stdout #91

Merged
merged 7 commits into from
May 15, 2023

Conversation

rhoban13
Copy link
Contributor

Logging inside subtests is not displayed unless the parent test fails. This PR proposes capturing logging for each subtest similar to how stdout/stderr is currently captured and displaying with similar granularity.

fixes #87

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @rhoban13, this looks excellent!

Besides my comments, could you please update the CHANGELOG? Thanks!

I will be happy to make a new release once this is merged. 👍

pytest_subtests.py Outdated Show resolved Hide resolved
pytest_subtests.py Outdated Show resolved Hide resolved
tests/test_subtests.py Outdated Show resolved Hide resolved
@@ -176,14 +177,27 @@ def _capturing_output(self):
fixture.close()
captured.out = out
captured.err = err

@contextmanager
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticing the comment on line 154 above "# capsys or capfd are active, subtest should not capture". Do I need to do anything similar if the caplog fixture is active?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, the logging capture supports multiple logs being captured at the same time, which is not true for capsys/capfd. 👍

@rhoban13 rhoban13 force-pushed the logging_in_subtests branch from 5524165 to 4f39650 Compare May 14, 2023 01:13
@rhoban13 rhoban13 force-pushed the logging_in_subtests branch from 4f39650 to 9430a59 Compare May 14, 2023 01:19
@nicoddemus nicoddemus merged commit 9ec1dcb into pytest-dev:main May 15, 2023
@nicoddemus
Copy link
Member

Thanks @rhoban13!

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

Successfully merging this pull request may close these issues.

Logging in subtests is not displayed unless the parent test fails
2 participants