Replies: 2 comments
-
|
Static methods ought not to matter, |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I agree with @RonnyPfannschmidt that your problem is somewhere else, but it's impossible to say more with so little information. This, for example, works just fine: import pytest
import warnings
class Warner:
@staticmethod
def warn():
warnings.warn("Test", UserWarning)
def test_warner():
warner = Warner()
with pytest.warns(UserWarning, match="Test"):
warner.warn() |
Beta Was this translation helpful? Give feedback.
0 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.
-
Does
pytest.warnshave a limitation when raising a warning from within astaticmethod?If I wrap a
staticmethodcall in awith pytest.warnsmy test fails with a 'Failed: DID NOT WARN' but if I remove thewithblock then the warnings are printed tostdoutBeta Was this translation helpful? Give feedback.
All reactions