pyenv verification source
Some checks are pending
macos_build / macos_build (3.10) (push) Waiting to run
macos_build / macos_build (3.11) (push) Waiting to run
macos_build / macos_build (3.12) (push) Waiting to run
macos_build / macos_build (3.13) (push) Waiting to run
macos_build / macos_build (3.14) (push) Waiting to run
pyenv_tests / pyenv_tests (macos-14) (push) Waiting to run
pyenv_tests / pyenv_tests (macos-15) (push) Waiting to run
pyenv_tests / pyenv_tests (macos-15-intel) (push) Waiting to run
pyenv_tests / pyenv_tests (macos-26) (push) Waiting to run
pyenv_tests / pyenv_tests (ubuntu-22.04) (push) Waiting to run
pyenv_tests / pyenv_tests (ubuntu-24.04) (push) Waiting to run
ubuntu_build / ubuntu_build (3.10) (push) Waiting to run
ubuntu_build / ubuntu_build (3.11) (push) Waiting to run
ubuntu_build / ubuntu_build (3.12) (push) Waiting to run
ubuntu_build / ubuntu_build (3.13) (push) Waiting to run
ubuntu_build / ubuntu_build (3.14) (push) Waiting to run
Some checks are pending
macos_build / macos_build (3.10) (push) Waiting to run
macos_build / macos_build (3.11) (push) Waiting to run
macos_build / macos_build (3.12) (push) Waiting to run
macos_build / macos_build (3.13) (push) Waiting to run
macos_build / macos_build (3.14) (push) Waiting to run
pyenv_tests / pyenv_tests (macos-14) (push) Waiting to run
pyenv_tests / pyenv_tests (macos-15) (push) Waiting to run
pyenv_tests / pyenv_tests (macos-15-intel) (push) Waiting to run
pyenv_tests / pyenv_tests (macos-26) (push) Waiting to run
pyenv_tests / pyenv_tests (ubuntu-22.04) (push) Waiting to run
pyenv_tests / pyenv_tests (ubuntu-24.04) (push) Waiting to run
ubuntu_build / ubuntu_build (3.10) (push) Waiting to run
ubuntu_build / ubuntu_build (3.11) (push) Waiting to run
ubuntu_build / ubuntu_build (3.12) (push) Waiting to run
ubuntu_build / ubuntu_build (3.13) (push) Waiting to run
ubuntu_build / ubuntu_build (3.14) (push) Waiting to run
This commit is contained in:
119
test/shell.bats
Normal file
119
test/shell.bats
Normal file
@@ -0,0 +1,119 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
|
||||
@test "shell integration disabled" {
|
||||
run pyenv shell
|
||||
assert_failure "pyenv: shell integration not enabled. Run \`pyenv init' for instructions."
|
||||
}
|
||||
|
||||
@test "shell integration enabled" {
|
||||
eval "$(pyenv init -)"
|
||||
run pyenv shell
|
||||
assert_success "pyenv: no shell-specific version configured"
|
||||
}
|
||||
|
||||
@test "no shell version" {
|
||||
mkdir -p "${PYENV_TEST_DIR}/myproject"
|
||||
cd "${PYENV_TEST_DIR}/myproject"
|
||||
echo "1.2.3" > .python-version
|
||||
PYENV_VERSION="" run pyenv-sh-shell
|
||||
assert_failure "pyenv: no shell-specific version configured"
|
||||
}
|
||||
|
||||
@test "shell version" {
|
||||
PYENV_SHELL=bash PYENV_VERSION="1.2.3" run pyenv-sh-shell
|
||||
assert_success 'echo "$PYENV_VERSION"'
|
||||
}
|
||||
|
||||
@test "shell version (fish)" {
|
||||
PYENV_SHELL=fish PYENV_VERSION="1.2.3" run pyenv-sh-shell
|
||||
assert_success 'echo "$PYENV_VERSION"'
|
||||
}
|
||||
|
||||
@test "shell version (pwsh)" {
|
||||
PYENV_SHELL=pwsh PYENV_VERSION="1.2.3" run pyenv-sh-shell
|
||||
assert_success 'echo "$PYENV_VERSION"'
|
||||
}
|
||||
|
||||
@test "shell revert" {
|
||||
PYENV_SHELL=bash run pyenv-sh-shell -
|
||||
assert_success
|
||||
assert_line 0 'if [ -n "${PYENV_VERSION_OLD+x}" ]; then'
|
||||
}
|
||||
|
||||
@test "shell revert (fish)" {
|
||||
PYENV_SHELL=fish run pyenv-sh-shell -
|
||||
assert_success
|
||||
assert_line 0 'if set -q PYENV_VERSION_OLD'
|
||||
}
|
||||
|
||||
@test "shell revert (pwsh)" {
|
||||
PYENV_SHELL=pwsh run pyenv-sh-shell -
|
||||
assert_success
|
||||
assert_line 0 'if ( Get-Item -Path Env:\PYENV_VERSION* ) {'
|
||||
}
|
||||
|
||||
@test "shell unset" {
|
||||
PYENV_SHELL=bash run pyenv-sh-shell --unset
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
PYENV_VERSION_OLD="\${PYENV_VERSION-}"
|
||||
unset PYENV_VERSION
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "shell unset (fish)" {
|
||||
PYENV_SHELL=fish run pyenv-sh-shell --unset
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
set -gu PYENV_VERSION_OLD "\$PYENV_VERSION"
|
||||
set -e PYENV_VERSION
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "shell unset (pwsh)" {
|
||||
PYENV_SHELL=pwsh run pyenv-sh-shell --unset
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
\$Env:PYENV_VERSION, \$Env:PYENV_VERSION_OLD = \$null, \$Env:PYENV_VERSION
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "shell change invalid version" {
|
||||
run pyenv-sh-shell 1.2.3
|
||||
assert_failure
|
||||
assert_output <<SH
|
||||
pyenv: version \`1.2.3' not installed
|
||||
false
|
||||
SH
|
||||
}
|
||||
|
||||
@test "shell change version" {
|
||||
mkdir -p "${PYENV_ROOT}/versions/1.2.3"
|
||||
PYENV_SHELL=bash run pyenv-sh-shell 1.2.3
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
PYENV_VERSION_OLD="\${PYENV_VERSION-}"
|
||||
export PYENV_VERSION="1.2.3"
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "shell change version (fish)" {
|
||||
mkdir -p "${PYENV_ROOT}/versions/1.2.3"
|
||||
PYENV_SHELL=fish run pyenv-sh-shell 1.2.3
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
set -gu PYENV_VERSION_OLD "\$PYENV_VERSION"
|
||||
set -gx PYENV_VERSION "1.2.3"
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "shell change version (pwsh)" {
|
||||
mkdir -p "${PYENV_ROOT}/versions/1.2.3"
|
||||
PYENV_SHELL=pwsh run pyenv-sh-shell 1.2.3
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
\$Env:PYENV_VERSION, \$Env:PYENV_VERSION_OLD = "1.2.3", \$Env:PYENV_VERSION
|
||||
OUT
|
||||
}
|
||||
Reference in New Issue
Block a user