mirror of
https://github.com/pyenv/pyenv.git
synced 2024-12-23 08:03:09 +00:00
79 lines
2 KiB
Bash
79 lines
2 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load test_helper
|
|
|
|
@test "creates shims and versions directories" {
|
|
assert [ ! -d "${PYENV_ROOT}/shims" ]
|
|
assert [ ! -d "${PYENV_ROOT}/versions" ]
|
|
run pyenv-init -
|
|
assert_success
|
|
assert [ -d "${PYENV_ROOT}/shims" ]
|
|
assert [ -d "${PYENV_ROOT}/versions" ]
|
|
}
|
|
|
|
@test "auto rehash" {
|
|
run pyenv-init -
|
|
assert_success
|
|
assert_line "pyenv rehash 2>/dev/null"
|
|
}
|
|
|
|
@test "setup shell completions" {
|
|
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
|
run pyenv-init - bash
|
|
assert_success
|
|
assert_line "source '${root}/libexec/../completions/pyenv.bash'"
|
|
}
|
|
|
|
@test "detect parent shell" {
|
|
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
|
SHELL=/bin/false run pyenv-init -
|
|
assert_success
|
|
assert_line "export PYENV_SHELL=bash"
|
|
}
|
|
|
|
@test "setup shell completions (fish)" {
|
|
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
|
run pyenv-init - fish
|
|
assert_success
|
|
assert_line ". '${root}/libexec/../completions/pyenv.fish'"
|
|
}
|
|
|
|
@test "fish instructions" {
|
|
run pyenv-init fish
|
|
assert [ "$status" -eq 1 ]
|
|
assert_line 'status --is-interactive; and . (pyenv init -|psub)'
|
|
}
|
|
|
|
@test "option to skip rehash" {
|
|
run pyenv-init - --no-rehash
|
|
assert_success
|
|
refute_line "pyenv rehash 2>/dev/null"
|
|
}
|
|
|
|
@test "adds shims to PATH" {
|
|
export PATH="${BATS_TEST_DIRNAME}/../libexec:/usr/bin:/bin:/usr/local/bin"
|
|
run pyenv-init - bash
|
|
assert_success
|
|
assert_line 0 'export PATH="'${PYENV_ROOT}'/shims:${PATH}"'
|
|
}
|
|
|
|
@test "adds shims to PATH (fish)" {
|
|
export PATH="${BATS_TEST_DIRNAME}/../libexec:/usr/bin:/bin:/usr/local/bin"
|
|
run pyenv-init - fish
|
|
assert_success
|
|
assert_line 0 "setenv PATH '${PYENV_ROOT}/shims' \$PATH"
|
|
}
|
|
|
|
@test "doesn't add shims to PATH more than once" {
|
|
export PATH="${PYENV_ROOT}/shims:$PATH"
|
|
run pyenv-init - bash
|
|
assert_success
|
|
refute_line 'export PATH="'${PYENV_ROOT}'/shims:${PATH}"'
|
|
}
|
|
|
|
@test "doesn't add shims to PATH more than once (fish)" {
|
|
export PATH="${PYENV_ROOT}/shims:$PATH"
|
|
run pyenv-init - fish
|
|
assert_success
|
|
refute_line 'setenv PATH "'${PYENV_ROOT}'/shims" $PATH ;'
|
|
}
|