Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 444 Bytes

PT015.md

File metadata and controls

28 lines (19 loc) · 444 Bytes

PT015

assertion always fails, replace with pytest.fail()

Examples

Bad code:

def test_foo():
    if some_condition:
        assert False, 'some_condition was True'

Good code:

import pytest

def test_foo():
    if some_condition:
        pytest.fail('some_condition was True')

Rationale

  • to enforce consistency across all tests in a codebase
  • to improve readability of test code and error messages