-
Notifications
You must be signed in to change notification settings - Fork 42
Add flag to show warnings #136
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
Conversation
pllim
left a comment
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.
Not clear from the doc if it can be used together with IGNORE_WARNINGS or is mutually exclusive with it.
Also would be curious to know how it interacts with filter_warnings set in setup.cfg, or inside a warnings.catch_warnings context manager.
It doesn't make sense to use both. But if you do I guess the inner call will win.
The goal is actually to override the default settings in setup.cfg (which for astropy turns warnings into exceptions)
It wraps the code, so the warnings that would be catch manually with catch_warnings would not be seen by the doctest flag. |
|
Re: #136 (comment) -- Can we document this in README? 😸 |
| .. code-block:: python | ||
| >>> import numpy as np | ||
| >>> np.mean([]) # doctest: +SHOW_WARNINGS |
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.
One more question: If the expected warning does not show, will doctest fail or ignore?
Is this the doctest equivalent of pytest.warns?
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.
One more question: If the expected warning does not show, will doctest fail or ignore?
Yep. I added more tests.
Is this the doctest equivalent of pytest.warns?
Yes, it can be seen as such.
pllim
left a comment
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.
Thanks! LGTM. I'll leave it open in case @astrofrog wants to review too.
astrofrog
left a comment
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.
Looks good to me, thanks!
|
Thanks. Will need a release ;) |
The previous minimum required version was 0.2.0. However, Astropy documentation testing makes use of the '+SHOW_WARNINGS' option, which was introduced by scientific-python/pytest-doctestplus#136 and therefore the actual minimum required pytest-doctestplus version is 0.9.0.
For astropy/astropy#11137
Basically copy/pasted from IGNORE_WARNINGS