pytest.raises gotcha Sean Gillies 2020-03-30 19:45 Exceptions are an aspect of a Python package's API and require testing. Pytest provides a handy context manager for this. def test_raises_an_error(): with pytest.raises(AnError): raise AnError