
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
pytest-watcher
Advanced tools
pytest-watcher is a tool to automatically rerun tests (using pytest by default) whenever your code changes.
Works on Unix (Linux, MacOS, BSD) and Windows.
Example:

pytest-watch has been around for a long time and used to address exactly this problem. Unfortunately, pytest-watch is no longer maintained and doesn't work for many users. This project provides an alternative for it.
See also: Differences with pytest-watch
By default pytest-watcher looks for the following events:
*.py file created*.py file modified*.py file deleted*.py file moved either from or to the watched pathYou can specify alternative file patterns to watch. See Watching different patterns
pip install pytest-watcher
Specify the path that you want to watch:
ptw .
or
ptw /home/repos/project
pytest-watcher will pass any arguments (excepted reserved options) after <path> to the test runner (which is pytest by default). For example:
ptw . -x --lf --nf
will call pytest with the following arguments:
pytest -x --lf --nf
The following options are reserved for pytest-watcher and will not be passed to the test runner:
--runner - Specify an alternative test runner--patterns - Specify file patterns to watch--ignore-patterns - Specify file patterns to ignore--now - Run tests immediately after starting the watcher--delay - Specify the delay before running tests--clear - Clear the terminal screen before each test run--notify-on-failure - Send BEL notification on test run failureYou can specify an alternative test runner using the --runner flag:
ptw . --runner tox
You can use the --patterns flag to specify file patterns that you want to watch. It accepts a list of Unix-style patterns separated by a comma. The default value is "*.py"
Example:
ptw . --patterns '*.py,pyproject.toml'
You can also ignore certain patterns using the --ignore-patterns flag:
ptw . --ignore-patterns 'settings.py,db.py'
pytest-watcher uses a short delay (0.2 seconds by default) before triggering the actual test run. The main motivation for this is post-processors that can run after you save the file (for example, black plugin in your IDE). This ensures that tests will run with the latest version of your code.
You can control the actual delay value with the --delay flag:
ptw . --delay 0.2
To disable the delay altogether, you can set zero as a value:
ptw . --delay 0
Use the --clear flag to clear the terminal screen before each test run
ptw . --clear
Use the --notify-on-failure flag to emit the BEL symbol to the terminal when the test run fails. This will trigger an audible or visual alert in some terminal applications.
ptw . --notify-on-failure
pytest-watchEven though this project was inspired by pytest-watch, it's not a fork of it. Therefore, there are differences in behavior:
pytest-watcher needs you to specify a path to watch as a first argument:ptw .
pytest-watcher doesn't start tests immediately by default. You can customize this behavior using --now flag.You can configure pytest-watcher via pyproject.toml file. Here is the default configuration:
[tool.pytest-watcher]
now = false
clear = true
notify_on_failure = false
delay = 0.2
runner = "pytest"
runner_args = []
patterns = ["*.py"]
ignore_patterns = []
The code is compatible with Python versions 3.9+
This project is licensed under the MIT License.
FAQs
Automatically rerun your tests on file modifications
We found that pytest-watcher demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.