Skip to content

Instantly share code, notes, and snippets.

@dseeni
Forked from BARJ/pre-commit.run-pytest.sh
Created May 4, 2019 17:04
Show Gist options
  • Select an option

  • Save dseeni/f79f68ee13083c6d710860d6bcbe7d4c to your computer and use it in GitHub Desktop.

Select an option

Save dseeni/f79f68ee13083c6d710860d6bcbe7d4c 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment