helpers for asserting deprecation and other warnings.
You can use the recwarn funcarg to track warnings within a test function:
def test_hello(recwarn):
from warnings import warn
warn("hello", DeprecationWarning)
w = recwarn.pop(DeprecationWarning)
assert issubclass(w.category, DeprecationWarning)
assert 'hello' in str(w.message)
assert w.filename
assert w.lineno
You can also call a global helper for checking taht a certain function call yields a Deprecation warning:
import py
def test_global():
py.test.deprecated_call(myfunction, 17)
Return a WarningsRecorder instance that provides these methods:
Checkout customize, other plugins or get in contact.