From 0fadebf7d80505b6b16543a7c0ec4cba8703bcec Mon Sep 17 00:00:00 2001 From: Kenneth Reitz <me@kennethreitz.org> Date: Fri, 10 Mar 2017 12:37:11 -0500 Subject: [PATCH] more tests --- bin/steps/pipenv-python-version | 5 +++-- bin/steps/python | 4 +++- test/fixtures/nltk/nltk.txt | 1 + test/fixtures/nltk/requirements.txt | 1 + test/fixtures/pipenv-version/Pipfile.lock | 23 +++++++++++++++++++++++ test/run | 17 +++++++++++++++++ 6 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 test/fixtures/nltk/nltk.txt create mode 100644 test/fixtures/nltk/requirements.txt create mode 100644 test/fixtures/pipenv-version/Pipfile.lock diff --git a/bin/steps/pipenv-python-version b/bin/steps/pipenv-python-version index e49813a3..a279da92 100755 --- a/bin/steps/pipenv-python-version +++ b/bin/steps/pipenv-python-version @@ -1,10 +1,11 @@ # Detect Python-version with Pipenv. -if [[ -f $BUILD_DIR/Pipfile.lock ]]; then +if [[ -f $BUILD_DIR/Pipfile ]]; then if [[ ! -f $BUILD_DIR/runtime.txt ]]; then if [[ ! -f Pipfile.lock ]]; then - pipenv lock 2> /dev/null + puts-step "Pipfile.lock not found, creating..." + /app/.heroku/python/bin/pipenv lock 2> /dev/null fi set +e diff --git a/bin/steps/python b/bin/steps/python index b88631b4..141ea89c 100755 --- a/bin/steps/python +++ b/bin/steps/python @@ -39,7 +39,9 @@ if [ ! "$SKIP_INSTALL" ]; then fi # If Pip isn't up to date: -if [ "$FRESH_PYTHON" ] || [[ ! $(pip --version) == *$PIP_VERSION* ]]; then +if [ "$FRESH_PYTHON" ] || pip list -o --format=legacy --disable-pip-version-check | grep '^pip' 2>&1 /dev/null; then + + # TODO: automatically detect pip is out of date with 'pip list -o --format=legacy --disable-pip-version-check | grep '^pip'' WORKING_DIR=$(pwd) TMPTARDIR=$(mktemp -d) diff --git a/test/fixtures/nltk/nltk.txt b/test/fixtures/nltk/nltk.txt new file mode 100644 index 00000000..c4f6bba8 --- /dev/null +++ b/test/fixtures/nltk/nltk.txt @@ -0,0 +1 @@ +wordnet \ No newline at end of file diff --git a/test/fixtures/nltk/requirements.txt b/test/fixtures/nltk/requirements.txt new file mode 100644 index 00000000..6fa2de44 --- /dev/null +++ b/test/fixtures/nltk/requirements.txt @@ -0,0 +1 @@ +nltk \ No newline at end of file diff --git a/test/fixtures/pipenv-version/Pipfile.lock b/test/fixtures/pipenv-version/Pipfile.lock new file mode 100644 index 00000000..15f40775 --- /dev/null +++ b/test/fixtures/pipenv-version/Pipfile.lock @@ -0,0 +1,23 @@ +{ + "default": { + "requests": { + "version": "==2.13.0", + "hash": "sha256:1a720e8862a41aa22e339373b526f508ef0c8988baf48b84d3fc891a8e237efb" + } + }, + "develop": {}, + "_meta": { + "sources": [ + { + "url": "https://pypi.python.org/simple", + "verify_ssl": true + } + ], + "requires": { + "python_version": "3.6" + }, + "hash": { + "sha256": "5866990104fc8f27d13cdf01abc2a32c553129e03f666316cacc5b42d3e0884e" + } + } +} \ No newline at end of file diff --git a/test/run b/test/run index bdb52ec7..bc1f2e14 100755 --- a/test/run +++ b/test/run @@ -1,11 +1,28 @@ #!/usr/bin/env bash + + testNoRequirements() { compile "no-requirements" assertCapturedError } +testNLTK() { + compile "nltk" + assertCaptured "wordnet" + assertCapturedSuccess + +} + + +testPipenvVersion() { + compile "pipenv-version" + assertCaptured "3.6.0" + assertCapturedSuccess +} + + testPipenv() { compile "pipenv" assertCapturedSuccess -- GitLab