Search code examples
djangodjango-testingcoverage.py

coverage.py not reporting error from run command


I have a bash script that runs my tests:

#!/bin/bash
coverage run --source='directory_for_coverage' manage.py test
coverage report --fail-under=87

but when I run the script it only returns an error code if the coverage fails, not if one of the tests fails. I would think that because I am not using the --ignore-errors switch that coverage run should return the error code from the failing test. What am I missing?


Solution

  • I solved this by adding a set -e command to my script:

    #!/bin/bash
    set -e
    coverage run --source='directory_for_coverage' manage.py test
    coverage report --fail-under=87