pytest-watcher is a command-line interface (CLI) tool that automatically reruns your Python tests (using pytest by default) whenever your code changes. It is a maintained alternative to the unmaintained `pytest-watch` and is designed to streamline the test-driven development (TDD) workflow by providing continuous test feedback. The current version is 0.6.3, and it supports Unix (Linux, MacOS, BSD) and Windows.
pip install pytest-watcherVerified import paths — ran on the pinned version, not inferred.
Navigate to your project directory and run `ptw .` to start watching for file changes. It will automatically detect Python files (`*.py` by default) and re-run your pytest suite upon modification.
Uninstall `pytest-watch` and install `pytest-watcher` (`pip install pytest-watcher`). Update any scripts or aliases to use the new tool if you were relying on specific behaviors of the old one.
Consult `ptw --help` to see `pytest-watcher`'s specific options. To pass arguments directly to pytest, separate them with `--`, e.g., `ptw . -- -x --lf`.
To disable or adjust the delay, use the `--delay` option. For immediate execution, you can set `--delay 0` (though this might lead to multiple test runs with very quick, successive saves).