Skip to content

Instantly share code, notes, and snippets.

@mfurquimdev
Created March 9, 2023 17:29
Show Gist options
  • Save mfurquimdev/74d8d28d50f959362d3b01820dc596b4 to your computer and use it in GitHub Desktop.
Save mfurquimdev/74d8d28d50f959362d3b01820dc596b4 to your computer and use it in GitHub Desktop.
Run unit pytests upon change on python files
#!/bin/bash
pipenv run pytest -s -vv --failed-first -x --cov-report term-missing --cov=. tests
#!/bin/bash
ppid=$$
function watch_file {
inotifywait -qm -r */ -e close_write --exclude ".*.pyc|.coverage|.pytest_cache|.mypy_cache" | while read -r path event filename;
do
echo -e "\033[1;7;37m$path$filename was $event\033[0;1;0m"
kill -s SIGUSR1 $ppid
done
}
watch_file & notify_pid="$!"
trap "{ kill --verbose -s SIGKILL -- $notify_pid $ppid; exit 255; }" SIGINT SIGTERM
trap "{ ./execute.sh; }" SIGUSR1
while :;
do
echo -n "."
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment