Skip to content

Watch mode

Watch mode monitors your project for file changes and reruns only the affected tests.

Basic usage

tryke watch

tryke watches all .py files in the project, respecting .gitignore. When a file changes, it:

  1. Identifies which modules were modified
  2. Walks the import graph to find all tests that depend on the changed modules
  3. Reruns only those tests

This gives you fast feedback without rerunning the entire suite.

How affected tests are determined

tryke builds a static import graph at startup (see test discovery). When a file changes, it traces the graph forward to find every test file that transitively imports the changed module, then reruns the tests in those files.

Files with dynamic imports (importlib.import_module(), __import__()) are always included in every rerun. See discovery for details.

Filtering

All the standard filtering flags work in watch mode:

# Only watch tests matching a name pattern
tryke watch -k "math"

# Only watch tests with specific tags
tryke watch -m "fast"

# Combine filters
tryke watch -k "parse" -m "not slow"

Options

Reporter

Choose an output format:

tryke watch --reporter dot

See reporters for all formats.

Fail fast

Stop a run on the first failure:

tryke watch -x

Or after N failures:

tryke watch --maxfail 3

Workers

Override the number of parallel workers (defaults to CPU count):

tryke watch -j 4

See concurrency for details on the worker pool.

Debouncing

File system events are debounced with a 200ms window. Rapid successive saves are coalesced into a single rerun.