Skip to content

Latest commit

 

History

History
40 lines (26 loc) · 628 Bytes

PT016.md

File metadata and controls

40 lines (26 loc) · 628 Bytes

PT016

no message passed to pytest.fail()

The function pytest.fail must be called either with a positional argument or a keyword argument msg=. Passing a keyword argument under a wrong name will also be reported as a violation.

Examples

Bad code:

import pytest

def test_foo():
    pytest.fail()

def test_bar():
    pytest.fail('')

def test_baz():
    pytest.fail(reason='...')  # wrong kwarg name

Good code:

import pytest

def test_foo():
    pytest.fail('...')

def test_bar():
    pytest.fail(msg='...')

Rationale

  • to make it easier to understand and debug test failures