watchmedo shell-command --patterns="*.py" --ignore-directories --recursive . -c "pytest"
It seems that there is no need to create one tool per command you wish to run. Or am I missing something? Do you only reload tests that are related to the code change?
watchmedo shell-command --patterns="\*.py" --ignore-directories --recursive . -c "pytest"
In my tool, there is a 0.5 seconds delay (configurable --delay). pytest-watcher will wait this time for other changes before starting pytest.
Regarding running tests for changed code only, there is a pytest-testmon plugin which does exactly that. It can be used together with pytest-watcher. Here is the link:
That's what the --drop options is for. It's better than delay, since it drops any event while the command is running, no matter the time it took.
> First, I think for many users typing: ... is a lot simpler than typing:...
I think somebody using pytest is perfectly capable of doing:
alias ptw='watchmedo shell-command --patterns="*.py" --ignore-directories --recursive . -c "pytest" --drop'
Or putting that in a makefile, a dodo.py file or what have you.
Install pytest and pytest-xdist, then run:
rg --files <dir> | entr -- pytest <args>...