This is how you can watch for changes to your source file and re-run the test on change with pytest.
Then you can use the
ptw command in place of
Use this command and pass the path of both the source and the test files. Thus, changes to either will be watched. Imagine a file structure like:
├── __init__.py ├── module.py ├── module_test.py
Match the test and source pattern at once with a substring:
Now changes to either file will re-run the test.