Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions cli/test_pack_python3.bats
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@

load '../test_helpers/bats-support/load'
load '../test_helpers/bats-assert/load'



STATUS_SUCCESS='"status": "succeeded'

setup() {
Expand Down Expand Up @@ -36,9 +33,12 @@ teardown() {
st2 run packs.uninstall packs=examples
fi
[[ ! -d /opt/stackstorm/packs/examples ]]
}


if [[ -d /opt/stackstorm/packs/python3_test ]]; then
st2 run packs.uninstall packs=python3_test
fi
[[ ! -d /opt/stackstorm/packs/python3_test ]]
}

@test "packs.setup_virtualenv without python3 flags works and defaults to Python 2" {
SETUP_VENV_RESULTS=$(st2 run packs.setup_virtualenv packs=examples -j)
Expand All @@ -65,7 +65,6 @@ teardown() {

run eval "echo '$SETUP_VENV_RESULTS' | jq -r '.status'"
assert_success

assert_output "succeeded"

run /opt/stackstorm/virtualenvs/examples/bin/python --version
Expand All @@ -84,4 +83,28 @@ teardown() {

run eval "echo '$RESULT' | jq -r '.status'"
assert_output "succeeded"

# Verify PYTHONPATH is correct
RESULT=$(st2 run examples.python_runner_print_python_environment -j)
assert_success

run eval "echo '$RESULT' | jq -r '.result.stdout'"
assert_success
assert_output --regexp ".*PYTHONPATH: /usr/(local/)?lib/python3.*"
}

@test "python3 imports work correctly" {
run st2 pack install python3_test --python3 -j
assert_success

RESULT=$(st2 run python3_test.test_stdlib_import -j)
assert_success

run eval "echo '$RESULT' | jq -r '.result.result'"
assert_success
assert_output --partial "imports work correctly"

run eval "echo '$RESULT' | jq -r '.result.stdout'"
assert_success
assert_output --partial "Using Python version: 3."
}