Skip to content

Latest commit

 

History

History
30 lines (19 loc) · 358 Bytes

PT029.md

File metadata and controls

30 lines (19 loc) · 358 Bytes

PT029

set the expected warning in pytest.warns()

Examples

Bad code:

import pytest

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

Good code:

import pytest

def test_foo():
    with pytest.warns(SomeWarning):
        do_something()

Rationale

  • not passing the warning class will fail at runtime