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.warns
have a limitation when raising a warning from within astaticmethod
?If I wrap a
staticmethod
call in awith pytest.warns
my test fails with a 'Failed: DID NOT WARN' but if I remove thewith
block then the warnings are printed tostdout
Beta Was this translation helpful? Give feedback.
All reactions