Skip to main content
Sean Gillies
  • About
  • Tags
  • Feed
  • Archive

    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
    
    • exceptions
    • pytest
    • python
    • testing
    • work
    • Previous post
    Contents © 2020 Sean Gillies - Powered by Nikola