Changed mode
Changed mode uses git to detect which files have been modified and runs only the tests affected by those changes.
--changed
Run only tests affected by uncommitted changes:
This compares the working tree against HEAD, finds changed .py files, then uses the import graph to identify every test that transitively depends on a changed module.
--changed-first
Run affected tests first, then run the rest of the suite:
This gives you fast feedback on what you just changed while still verifying the full suite in the same run.
--base-branch
Compare against a branch instead of HEAD:
This uses git merge-base to find the common ancestor and diffs from there. Useful in CI to run only tests affected by a pull request:
--base-branch works with both --changed and --changed-first.
How it works
- tryke runs
git diffto find changed.pyfiles - The static import graph (see test discovery) maps each changed file to the test files that depend on it
- Only the affected test files are collected and run
Files with dynamic imports are always included — see discovery.
Combining with other filters
Changed mode composes with all other flags:
# Only changed tests matching a name pattern
tryke test --changed -k "parse"
# Only changed tests with a specific tag
tryke test --changed -m "unit"
# Changed-first with fail-fast
tryke test --changed-first -x
Visualizing the impact
Use tryke graph --changed to see which files are affected without running any tests: