Skip to content

Latest commit

 

History

History
30 lines (19 loc) · 367 Bytes

PT010.md

File metadata and controls

30 lines (19 loc) · 367 Bytes

PT010

set the expected exception in pytest.raises()

Examples

Bad code:

import pytest

def test_foo():
    with pytest.raises():
        do_something()

Good code:

import pytest

def test_foo():
    with pytest.raises(SomeException):
        do_something()

Rationale

  • not passing the exception class will fail at runtime