pytest-flakes
raw JSON → 4.0.5 verified Fri May 01 auth: no python
A pytest plugin that checks Python source code for logical errors using pyflakes. It integrates seamlessly into the pytest ecosystem, automatically running pyflakes on all collected test files and source files. Current version 4.0.5 supports Python >=3.5. The plugin is in maintenance mode; no new features are expected.
pip install pytest-flakes Common errors
error ModuleNotFoundError: No module named 'pyflakes' ↓
cause Missing dependency pyflakes
fix
pip install pyflakes
error ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...] pytest: error: unrecognized arguments: --flakes ↓
cause pytest-flakes is not installed or not activated
fix
pip install pytest-flakes and ensure it's in the test environment
Warnings
gotcha The plugin checks all collected Python files, not just test files. This can cause unexpected failures in third-party code if you have a large source tree. Use --flakes-ignore to exclude files. ↓
fix Configure pytest.ini with flakes-ignore = path/to/ignore*
gotcha Does not work with Python 3.10+? Actually, pyflakes supports up to Python 3.8. But pytest-flakes may still work with newer Python as long as pyflakes parses the code. However, there may be false negatives for newer syntax (match statements, etc.). ↓
fix Consider using flake8 for modern Python syntax support.
Imports
- pytest_flakes wrong
from pytest_flakes import ...correctimport pytest_flakes
Quickstart
import pytest
import sys
sys.path.insert(0, 'src')
def test_ok():
x = 1
assert x