I really missed assertRaisesRegexp in unittest module from pytest
,
so I wrote this simple plugin.
# some_module.py
class ExpectedException():
pass
def function_to_test():
raise ExpectedException('error message: 1560')
# test_some_module.py
from pytest import raises_regexp
from some_module import function_to_test, ExpectedException
def test_something_to_test():
with raises_regexp(ExpectedException, r".* 1560"):
function_to_test()
$ pip install pytest-raisesregexp
It installs as a pytest entry point, so you can:
from pytest import raises_regexp
MIT license