Replies: 2 comments 2 replies
-
I'm not too familiar with doctests, but what about turning warnings into errors ( class tst:
"""
>>> import warnings
>>> warnings.warn("foo")
Traceback (most recent call last):
...
UserWarning: foo
"""
pass |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In order to test warnings in docstrings of functions and classes, it appears necessary to monkey-patch
warnings.showwarning
,e.g. as follows
Then
pytest --doctest-modules -p no:warnings c.py
passes - otherwise it does not get any output ofwarn()
call, and the test fails.Is there a more standard way to accomplish this? Obviously monkey-patching of the standard library is not what one should normally do.
Beta Was this translation helpful? Give feedback.
All reactions