flake8-pytest-style
flake8-pytest-style copied to clipboard
Rule to disallow conditional test definition
Rule request
Description
Test definition should not be placed in a top-level if block. pytest.mark.skipif() should be used instead, if necessary.
Bad code:
if sys.platform == 'win32':
def test_on_windows_only():
...
Good code:
@pytest.mark.skipif(sys.platform != 'win32', reason='windows only')
def test_on_windows_only():
...
Rationale
- for consistency
- to make such conditionally skipped tests appear in the report