Add bin/test
to detect and trigger unit tests
#982
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
Most Heroku buildpacks have a
bin/test
script that runs application unit tests (e.g the Ruby & PHP buildpacks), but it appears that the Python buildpack is currently missing one.Implementation
I have taken inspiration from the PHP buildpack's test script, and added support for detecting the unit test framework used by grepping through
Pipfile
orrequirements.txt
.So far, I have added support for Pytest, Nose, Nose2, Python's unittest module, as well as Django's unit functionality. I have also added the ability to define a custom unit test command by defining the command as the value of the
UNIT_TEST_COMMAND
environment variable so that the user has some flexibility.Buildpack unit tests have also been added to confirm that the functionality is correct.
In Practice
This functionality probably isn't used on the Heroku platform since it is missing, but it is useful when using the buildpack outside of Heroku, most noticeably with Herokuish (i.e. it addresses the Python part of gliderlabs/herokuish#349).