2014-01-02 11:48:22 -05:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
|
|
|
|
create_version() {
|
|
|
|
mkdir -p "${PYENV_ROOT}/versions/$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
mkdir -p "$PYENV_TEST_DIR"
|
|
|
|
cd "$PYENV_TEST_DIR"
|
|
|
|
}
|
|
|
|
|
|
|
|
stub_system_python() {
|
|
|
|
local stub="${PYENV_TEST_DIR}/bin/python"
|
|
|
|
mkdir -p "$(dirname "$stub")"
|
|
|
|
touch "$stub" && chmod +x "$stub"
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "no versions installed" {
|
|
|
|
stub_system_python
|
|
|
|
assert [ ! -d "${PYENV_ROOT}/versions" ]
|
|
|
|
run pyenv-versions
|
|
|
|
assert_success "* system (set by ${PYENV_ROOT}/version)"
|
|
|
|
}
|
|
|
|
|
2014-10-14 11:46:11 -04:00
|
|
|
@test "not even system python available" {
|
2021-09-15 17:34:00 -04:00
|
|
|
PATH="$(path_without python python2 python3)" run pyenv-versions
|
2014-10-14 11:46:11 -04:00
|
|
|
assert_failure
|
|
|
|
assert_output "Warning: no Python detected on the system"
|
|
|
|
}
|
|
|
|
|
2014-01-02 11:48:22 -05:00
|
|
|
@test "bare output no versions installed" {
|
|
|
|
assert [ ! -d "${PYENV_ROOT}/versions" ]
|
|
|
|
run pyenv-versions --bare
|
|
|
|
assert_success ""
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "single version installed" {
|
|
|
|
stub_system_python
|
2014-01-02 14:38:29 -05:00
|
|
|
create_version "3.3"
|
2014-01-02 11:48:22 -05:00
|
|
|
run pyenv-versions
|
|
|
|
assert_success
|
|
|
|
assert_output <<OUT
|
|
|
|
* system (set by ${PYENV_ROOT}/version)
|
2014-01-02 14:38:29 -05:00
|
|
|
3.3
|
2014-01-02 11:48:22 -05:00
|
|
|
OUT
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "single version bare" {
|
2014-01-02 14:38:29 -05:00
|
|
|
create_version "3.3"
|
2014-01-02 11:48:22 -05:00
|
|
|
run pyenv-versions --bare
|
2014-01-02 14:38:29 -05:00
|
|
|
assert_success "3.3"
|
2014-01-02 11:48:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "multiple versions" {
|
|
|
|
stub_system_python
|
2014-01-02 14:38:29 -05:00
|
|
|
create_version "2.7.6"
|
|
|
|
create_version "3.3.3"
|
|
|
|
create_version "3.4.0"
|
2014-01-02 11:48:22 -05:00
|
|
|
run pyenv-versions
|
|
|
|
assert_success
|
|
|
|
assert_output <<OUT
|
|
|
|
* system (set by ${PYENV_ROOT}/version)
|
2014-01-02 14:38:29 -05:00
|
|
|
2.7.6
|
|
|
|
3.3.3
|
|
|
|
3.4.0
|
2014-01-02 11:48:22 -05:00
|
|
|
OUT
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "indicates current version" {
|
|
|
|
stub_system_python
|
2014-01-02 14:38:29 -05:00
|
|
|
create_version "3.3.3"
|
|
|
|
create_version "3.4.0"
|
|
|
|
PYENV_VERSION=3.3.3 run pyenv-versions
|
2014-01-02 11:48:22 -05:00
|
|
|
assert_success
|
|
|
|
assert_output <<OUT
|
|
|
|
system
|
2014-01-02 14:38:29 -05:00
|
|
|
* 3.3.3 (set by PYENV_VERSION environment variable)
|
|
|
|
3.4.0
|
2014-01-02 11:48:22 -05:00
|
|
|
OUT
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "bare doesn't indicate current version" {
|
2014-01-02 14:38:29 -05:00
|
|
|
create_version "3.3.3"
|
|
|
|
create_version "3.4.0"
|
|
|
|
PYENV_VERSION=3.3.3 run pyenv-versions --bare
|
2014-01-02 11:48:22 -05:00
|
|
|
assert_success
|
|
|
|
assert_output <<OUT
|
2014-01-02 14:38:29 -05:00
|
|
|
3.3.3
|
|
|
|
3.4.0
|
2014-01-02 11:48:22 -05:00
|
|
|
OUT
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "globally selected version" {
|
|
|
|
stub_system_python
|
2014-01-02 14:38:29 -05:00
|
|
|
create_version "3.3.3"
|
|
|
|
create_version "3.4.0"
|
|
|
|
cat > "${PYENV_ROOT}/version" <<<"3.3.3"
|
2014-01-02 11:48:22 -05:00
|
|
|
run pyenv-versions
|
|
|
|
assert_success
|
|
|
|
assert_output <<OUT
|
|
|
|
system
|
2014-01-02 14:38:29 -05:00
|
|
|
* 3.3.3 (set by ${PYENV_ROOT}/version)
|
|
|
|
3.4.0
|
2014-01-02 11:48:22 -05:00
|
|
|
OUT
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "per-project version" {
|
|
|
|
stub_system_python
|
2014-01-02 14:38:29 -05:00
|
|
|
create_version "3.3.3"
|
|
|
|
create_version "3.4.0"
|
|
|
|
cat > ".python-version" <<<"3.3.3"
|
2014-01-02 11:48:22 -05:00
|
|
|
run pyenv-versions
|
|
|
|
assert_success
|
|
|
|
assert_output <<OUT
|
|
|
|
system
|
2014-01-02 14:38:29 -05:00
|
|
|
* 3.3.3 (set by ${PYENV_TEST_DIR}/.python-version)
|
|
|
|
3.4.0
|
2014-01-02 11:48:22 -05:00
|
|
|
OUT
|
|
|
|
}
|
2014-10-14 11:46:11 -04:00
|
|
|
|
|
|
|
@test "ignores non-directories under versions" {
|
|
|
|
create_version "3.3"
|
|
|
|
touch "${PYENV_ROOT}/versions/hello"
|
|
|
|
|
|
|
|
run pyenv-versions --bare
|
|
|
|
assert_success "3.3"
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "lists symlinks under versions" {
|
|
|
|
create_version "2.7.8"
|
|
|
|
ln -s "2.7.8" "${PYENV_ROOT}/versions/2.7"
|
|
|
|
|
|
|
|
run pyenv-versions --bare
|
|
|
|
assert_success
|
|
|
|
assert_output <<OUT
|
|
|
|
2.7
|
|
|
|
2.7.8
|
|
|
|
OUT
|
|
|
|
}
|
2015-10-27 05:49:29 -04:00
|
|
|
|
|
|
|
@test "doesn't list symlink aliases when --skip-aliases" {
|
|
|
|
create_version "1.8.7"
|
2015-11-20 23:13:52 -05:00
|
|
|
ln -s "1.8.7" "${PYENV_ROOT}/versions/1.8"
|
2015-10-27 05:49:29 -04:00
|
|
|
mkdir moo
|
2015-11-20 23:13:52 -05:00
|
|
|
ln -s "${PWD}/moo" "${PYENV_ROOT}/versions/1.9"
|
2015-10-27 05:49:29 -04:00
|
|
|
|
2015-11-20 23:13:52 -05:00
|
|
|
run pyenv-versions --bare --skip-aliases
|
2015-10-27 05:49:29 -04:00
|
|
|
assert_success
|
|
|
|
|
|
|
|
assert_output <<OUT
|
|
|
|
1.8.7
|
|
|
|
1.9
|
|
|
|
OUT
|
|
|
|
}
|
2019-06-02 16:00:36 -04:00
|
|
|
|
|
|
|
@test "lists dot directories under versions" {
|
|
|
|
create_version ".venv"
|
|
|
|
|
|
|
|
run pyenv-versions --bare
|
|
|
|
assert_success ".venv"
|
|
|
|
}
|