pytest-cagoule
Pytest plugin to only run tests affected by changes
What it is and what it does
pytest-cagoule is a pytest plugin that uses coverage data to map which tests exercise which lines of code, then lets you run only the tests affected by your recent changes. After an initial full test run with coverage collection (using --cov --cov-context=test), you can specify a file path or use git diff to automatically identify changed code, and the plugin will select and run only the tests that touch those lines.
The plugin is designed for CI workflows where you want to speed up feedback by skipping unaffected tests. It has no runtime dependencies and integrates directly with pytest's command-line interface. However, it only captures coverage for code executed during test runs themselves, not module-level imports, so some code paths may be missed. The package is in alpha status and has been unmaintained since 2020.
Use it for:
- Speed up CI pipelines by running only tests affected by a pull request's changes.
- Identify which tests exercise a specific file you're debugging or refactoring.
- Validate that a change to a utility module doesn't break tests in dependent modules.
- Reduce local test cycle time during development by running only affected tests after code edits.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A pytest plugin that identifies which tests exercise code you've recently changed, allowing you to run only the affected subset instead of the full test suite.
No, not recommended for new projects. The package is abandoned (last release 2020-01-01, no maintenance since), has high install friction, and offers no guarantees of compatibility with modern pytest or coverage.py versions. While the core idea is sound, the lack of maintenance and unclear dependency requirements make it a poor choice. Consider actively maintained alternatives for test selection based on code coverage.
Install
pytest-cagoule on PyPI
pip
pip install pytest-cagouleuv
uv add pytest-cagoulepoetry
poetry add pytest-cagouleInstalling pytest-cagoule
Before you install
High install friction: the package is abandoned (last release 2020-01-01, no commits since), and no runtime dependencies are declared, suggesting it may require manual setup or external tools. Maintenance status is a significant concern for new projects.
License in practice
MIT license is permissive and imposes no restrictions on use, modification, or redistribution in your own projects.
Quickstart
pip install pytest-cagoule
# Collect coverage with test contexts
pytest --cov --cov-context=test
# Run tests touching a specific file
pytest --cagoule-select=path/to/file.py
# Or use git diff to find changed files
pytest --diff
Requires pytest and coverage.py to be installed separately; the plugin only captures lines executed during individual test runs, excluding module-level code executed at import time.
Verify before relying
- Whether the plugin works with current pytest and coverage.py versions (last release was 2020-01-01).
- Whether git integration (--diff flag) works reliably with modern git workflows.
- Performance impact when handling large test suites or many changed files.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | abandoned — 2,417 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 127,047/month — #11,755 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest-cagoule-0.4.0.tar.gz
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
pytest-covA pytest plugin that measures code coverage…
permissive · top 1,000 on PyPI
snob-libSnob analyzes your Python project's dependency…
permissive · top 15,000 on PyPI
pytest-split-testsA pytest plugin that splits your test suite…
permissive · top 15,000 on PyPI
pytest-catchlogA pytest plugin that automatically captures log…
permissive · top 15,000 on PyPI
pytest-cacheA pytest plugin that persists test state across…
permissive · top 15,000 on PyPI
diff-coverCompares test coverage reports against git…
permissive · top 1,000 on PyPI
pytest-test-groupspytest-test-groups is a pytest plugin that…
permissive · top 5,000 on PyPI
pytest-watchRuns pytest continuously, re-executing tests…
permissive · top 5,000 on PyPI
pytest-coverpytest-cover is a pytest plugin for measuring…
permissive · top 15,000 on PyPI
cov-corecov-core provides the internal plugin…
permissive · top 15,000 on PyPI