Skip to content

Instantly share code, notes, and snippets.

@BARJ
Created April 16, 2018 03:56
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save BARJ/e2744bfb60f858b0ada33e67fbc6e78f to your computer and use it in GitHub Desktop.
Save BARJ/e2744bfb60f858b0ada33e67fbc6e78f to your computer and use it in GitHub Desktop.
pre-commit hook that runs pytest
#!/bin/sh
RED='\033[0;31m'
NC='\033[0m' # No Color
test_results=$(script -q /dev/null pipenv run python -m pytest ./test -v --tb=no)
if [ $? -eq 1 ]; then
printf "${RED}CANNOT COMMIT, PYTEST FAILED\n\nPYTEST RESULTS:\n"
echo "$test_results"
exit 1
fi
# NO ERRORS
exit 0
@GiorgioSgl
Copy link

with poetry?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment