pytest-cagoule

raw JSON →
0.4.0 verified Mon Apr 27 auth: no python maintenance

pytest-cagoule is a pytest plugin that only runs tests affected by code changes, using static analysis to determine test dependencies. Current version 0.4.0 is in maintenance mode; no recent releases since 2021. It works by analyzing import graphs and git diff.

pip install pytest-cagoule
error pytest: error: unrecognized arguments: --cagoule
cause pytest-cagoule is not installed or not registered as a plugin.
fix
Reinstall: pip install pytest-cagoule. Ensure no typos in the flag.
error fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
cause The default base branch 'master' does not exist; repository uses 'main' or another name.
fix
Use --base-branch=main or the correct branch name.
error ModuleNotFoundError: No module named 'git'
cause GitPython dependency is missing.
fix
Install GitPython: pip install GitPython
deprecated pytest-cagoule is no longer actively maintained. Consider using pytest-testmon or pytest-watch as alternatives.
fix Switch to pytest-testmon (pip install pytest-testmon) and use --testmon flag.
gotcha The default base branch is 'master', which may not match your repository's default branch (e.g., 'main'). Tests may not run correctly if the branch name is wrong.
fix Use --base-branch=main explicitly if your primary branch is 'main'.
gotcha The plugin only analyzes import dependencies; it does not detect changes in non-imported files or dynamic imports. Tests affecting configuration files or data may be missed.
fix Manually include tests for changed configuration or data files.
breaking Requires a git repository and may fail if run outside a git working directory.
fix Ensure pytest is run inside a git repository with a valid git diff.

Run pytest with the --cagoule flag to only execute tests affected by changes compared to the base branch (default 'master').

# No configuration needed. Run pytest with --cagoule
# pytest --cagoule
# To specify a base branch:
# pytest --cagoule --base-branch=main