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

Add new capture option, "forget", to not print to stdout when test fails #1233

Closed
wants to merge 23 commits into from
Closed

Conversation

hamzasheikh
Copy link

Capture and display of output (--capture=fd) when tests fail is problematic in cases meeting these conditions:

  • Long test runs with many tests
  • Debug logging enabled (using Python's logging module) in all tests

I run tests through Jenkins and PyTest captures all output that makes reading through PyTest's own pertinent output cumbersome. Plus, since debug logs are already captured in files this output is redundant. Hence the need to add an option to "forget" capture.

This is proof of concept PR provides support for clean output while retaining everything else in logs (if they're being used).

Disclaimers:

  • I have tested this PoC with Python 3 only
  • I am still learning PyTest and made a lot of exploratory commits in trying to understand the code; the commit history is atrocious for that reason
  • My reasons for creating the PR are selfish: I'd rather this was supported in upstream instead of carrying my own patches
  • I am willing to learn more and clean up the code with PR review feedback

@RonnyPfannschmidt
Copy link
Member

Hi, thanks for the initial experiment, however I think that's the wrong place

Similar to how traceback formatting allows us to change display without giving up on the underlying data,
Capture display should have such an option

So it would be possible to show all output, truncated output or no output

As for the structure of the contribution, please try to squash commits into semanticall steps
so a PR can be concise and more easily read by us

@hamzasheikh
Copy link
Author

Thanks for reviewing and providing feedback. If I understand correctly, you're saying to use a flag similar to --tb=style that takes the capture and formats it before output?

@RonnyPfannschmidt
Copy link
Member

Correct :)

@hamzasheikh
Copy link
Author

Thanks. Closing this PR. Another PR shall be opened when I have something useful to show.

@hamzasheikh hamzasheikh closed this Dec 9, 2015
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.

3 participants