-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 ability to log warnings during pytest #2764
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2764 +/- ##
=========================================
- Coverage 84.82% 77.3% -7.52%
=========================================
Files 657 23 -634
Lines 37746 780 -36966
Branches 4537 81 -4456
=========================================
- Hits 32019 603 -31416
+ Misses 4395 149 -4246
+ Partials 1332 28 -1304 |
Not sure what you mean, if I try:
warning message is actually printed when I do
|
Right that's why we're using warnings here. I was talking about logging |
Can't we use |
Not really because the tests themselves likely wouldn't do this kind of logging but rather these warnings would come from elsewhere like utility functions or fixtures. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the current solution better 👍
Motivation
We need a way to output messages even for passing tests, such as when temporary directories could not be cleaned up. However, pytest captures output by default, so logs only get displayed upon failure or when using extra flags. Therefore we use their built-in warnings mechanism to elicit this behavior by default https://docs.pytest.org/en/latest/warnings.html. We also can output condensed messages so these look just as nice in terminal when not running tests.
Additional Notes
This needs to be merged before #2762, which in turn is required for #2760