Skip to content

Commit

Permalink
python: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
morpheu committed Jul 5, 2024
1 parent 3d6df11 commit 86f3f4f
Showing 1 changed file with 26 additions and 53 deletions.
79 changes: 26 additions & 53 deletions tests/python/tests.bats
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,32 @@ load 'bats-assert-master/load'
assert_success
}

@test "set 3.6 as default python version" {
export PYTHON_VERSION_DEFAULT=3.6.15
@test "set 3.9 as default python version" {
export PYTHON_VERSION_DEFAULT=3.9.15
run /var/lib/tsuru/deploy
[[ "$output" == *"Using python version: 3.6.15"* ]]
[[ "$output" == *"Using python version: 3.9.15"* ]]
assert_success

run python --version
assert_success
[[ "$output" == *"3.6.15"* ]]
[[ "$output" == *"3.9.15"* ]]

run pip freeze
assert_success
}

@test "parse python version from .python-version" {
echo "3.6.15" > ${CURRENT_DIR}/.python-version
echo "3.9.15" > ${CURRENT_DIR}/.python-version
run /var/lib/tsuru/deploy
assert_success
[[ "$output" == *"Using python version: 3.6.15"* ]]
[[ "$output" == *"Using python version: 3.9.15"* ]]

pushd ${CURRENT_DIR}
run python --version
popd

assert_success
[[ "$output" == *"3.6.15"* ]]
[[ "$output" == *"3.9.15"* ]]
}

@test "testing python compiled using dynamic shared lib" {
Expand All @@ -86,17 +86,17 @@ load 'bats-assert-master/load'


@test "parse python version from PYTHON_VERSION" {
export PYTHON_VERSION=3.6.15
export PYTHON_VERSION=3.9.15
run /var/lib/tsuru/deploy
assert_success
[[ "$output" == *"Using python version: 3.6.15"* ]]
[[ "$output" == *"Using python version: 3.9.15"* ]]

pushd ${CURRENT_DIR}
run python --version
popd

assert_success
[[ "$output" == *"3.6.15"* ]]
[[ "$output" == *"3.9.15"* ]]
unset PYTHON_VERSION
}

Expand Down Expand Up @@ -203,32 +203,32 @@ EOF
assert_success
[[ "$output" == *"3.11.3"* ]]

export PYTHON_VERSION=3.6.15
export PYTHON_VERSION=3.10.5
run /var/lib/tsuru/deploy
assert_success
run python --version

assert_success
[[ "$output" == *"3.6.15"* ]]
[[ "$output" == *"3.10.5"* ]]
unset PYTHON_VERSION
}

@test "reuses already installed python version" {
echo "3.6.15" > ${CURRENT_DIR}/.python-version
echo "3.9.15" > ${CURRENT_DIR}/.python-version
run /var/lib/tsuru/deploy
assert_success
[[ "$output" == *"Using python version: 3.6.15"* ]]
[[ "$output" == *"Using python version: 3.9.15"* ]]

pushd ${CURRENT_DIR}
run python --version
popd

assert_success
[[ "$output" == *"3.6.15"* ]]
[[ "$output" == *"3.9.15"* ]]

run /var/lib/tsuru/deploy
assert_success
[[ "$output" == *"Using already installed python version: 3.6.15"* ]]
[[ "$output" == *"Using already installed python version: 3.9.15"* ]]

pushd ${CURRENT_DIR}
run python --version
Expand All @@ -239,50 +239,32 @@ EOF
}

@test "change python version to closest version" {
export PYTHON_VERSION=3.6.x
run /var/lib/tsuru/deploy
assert_success
[[ "$output" == *"Using python version: 3.6.15 (PYTHON_VERSION environment variable (closest))"* ]]
run python --version

assert_success
[[ "$output" == *"3.6.15"* ]]

export PYTHON_VERSION=3.7.x
run /var/lib/tsuru/deploy
assert_success
[[ "$output" == *"Using python version: 3.7.16 (PYTHON_VERSION environment variable (closest))"* ]]
run python --version

assert_success
[[ "$output" == *"3.7.16"* ]]

export PYTHON_VERSION=3.7
export PYTHON_VERSION=3.9.x
run /var/lib/tsuru/deploy
assert_success
[[ "$output" == *"Using already installed python version: 3.7.16"* ]]
[[ "$output" == *"Using python version: 3.9.16 (PYTHON_VERSION environment variable (closest))"* ]]
run python --version

assert_success
[[ "$output" == *"3.7.16"* ]]
[[ "$output" == *"3.9.16"* ]]

export PYTHON_VERSION=3.8.x
export PYTHON_VERSION=3.10.x
run /var/lib/tsuru/deploy
assert_success
[[ "$output" == *"Using python version: 3.8.16 (PYTHON_VERSION environment variable (closest))"* ]]
[[ "$output" == *"Using python version: 3.10.11 (PYTHON_VERSION environment variable (closest))"* ]]
run python --version

assert_success
[[ "$output" == *"3.8.16"* ]]
[[ "$output" == *"3.10.11"* ]]

export PYTHON_VERSION=3.8
export PYTHON_VERSION=3.11
run /var/lib/tsuru/deploy
assert_success
[[ "$output" == *"Using already installed python version: 3.8.16"* ]]
[[ "$output" == *"Using already installed python version: 3.11.3"* ]]
run python --version

assert_success
[[ "$output" == *"3.8.16"* ]]
[[ "$output" == *"3.11.3"* ]]

export PYTHON_VERSION=3
run /var/lib/tsuru/deploy
Expand All @@ -295,15 +277,6 @@ EOF
assert_success
[[ "$output" == *"3.12.0"* ]]

export PYTHON_VERSION=3.6.x
run /var/lib/tsuru/deploy
assert_success
[[ "$output" == *"Using python version: 3.6.15 (PYTHON_VERSION environment variable (closest))"* ]]
run python --version

assert_success
[[ "$output" == *"3.6.15"* ]]

export PYTHON_VERSION=pypy2.7
run /var/lib/tsuru/deploy
assert_success
Expand Down Expand Up @@ -360,7 +333,7 @@ EOF
}

@test "can install uwsgi with python 3" {
echo "3.8" > ${CURRENT_DIR}/.python-version
echo "3.10" > ${CURRENT_DIR}/.python-version
echo "uwsgi==2.0.18" > ${CURRENT_DIR}/requirements.txt

run /var/lib/tsuru/deploy
Expand Down

0 comments on commit 86f3f4f

Please sign in to comment.