{"id":3777,"library":"pytest-watcher","title":"pytest-watcher","description":"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.","status":"active","version":"0.6.3","language":"en","source_language":"en","source_url":"https://github.com/olzhasar/pytest-watcher","tags":["pytest","testing","watcher","tdd","automation","cli"],"install":[{"cmd":"pip install pytest-watcher","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"It acts as a continuous test runner for pytest.","package":"pytest","optional":false},{"reason":"It uses the watchdog library for efficient filesystem event monitoring.","package":"watchdog","optional":false}],"imports":[{"note":"pytest-watcher is primarily a CLI tool and is not typically imported into Python code for its main functionality.","symbol":"ptw","correct":"Run from command line: ptw ."}],"quickstart":{"code":"# In your project directory with pytest tests:\n# Create a dummy test file (e.g., test_example.py)\n# def test_addition():\n#     assert 1 + 1 == 2\n\n# Run the watcher\nptw .","lang":"bash","description":"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."},"warnings":[{"fix":"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.","message":"pytest-watcher is a modern, maintained alternative to the older, unmaintained `pytest-watch` (also known as `ptw`). If you were using `pytest-watch`, be aware that it had known issues (e.g., with `pyproject.toml` parsing) which `pytest-watcher` aims to resolve. Migrate to `pytest-watcher` for ongoing support and compatibility.","severity":"breaking","affected_versions":"All versions (when migrating from pytest-watch)"},{"fix":"Consult `ptw --help` to see `pytest-watcher`'s specific options. To pass arguments directly to pytest, separate them with `--`, e.g., `ptw . -- -x --lf`.","message":"Arguments passed to `ptw` are either consumed by `pytest-watcher` itself or forwarded to the underlying test runner (pytest by default). Ensure you understand which arguments are reserved by `pytest-watcher` (e.g., `--runner`, `--patterns`, `--ignore-patterns`, `--delay`, `--clear`, `--now`, `--notify-on-failure`) and which will be passed to `pytest` (typically all arguments after a directory path or a `--` separator).","severity":"gotcha","affected_versions":"All versions"},{"fix":"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).","message":"pytest-watcher introduces a short default delay (0.2 seconds) before triggering a test run after a file change. This is intentional to debounce rapid saves (e.g., by IDE formatters) and allow post-processors to complete. If you require immediate test execution, this delay might be unexpected.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}