1
0
mirror of https://github.com/pyenv/pyenv.git synced 2025-11-12 21:33:54 -05:00

Merge pull request #290 from blueyed/version-handle-missing-better

Improve `pyenv version`, if there is one missing
This commit is contained in:
Yamashita, Yuu
2015-05-17 12:05:03 +09:00
4 changed files with 77 additions and 2 deletions

View File

@@ -52,6 +52,39 @@ setup() {
assert_failure "pyenv: version \`1.2' is not installed"
}
@test "one missing version (second missing)" {
create_version "3.4.2"
PYENV_VERSION="3.4.2:1.2" run pyenv-version-name
assert_failure
assert_output <<OUT
pyenv: version \`1.2' is not installed
3.4.2
OUT
}
@test "one missing version (first missing)" {
create_version "3.4.2"
PYENV_VERSION="1.2:3.4.2" run pyenv-version-name
assert_failure
assert_output <<OUT
pyenv: version \`1.2' is not installed
3.4.2
OUT
}
pyenv-version-name-without-stderr() {
pyenv-version-name 2>/dev/null
}
@test "one missing version (without stderr)" {
create_version "3.4.2"
PYENV_VERSION="1.2:3.4.2" run pyenv-version-name-without-stderr
assert_failure
assert_output <<OUT
3.4.2
OUT
}
@test "version with prefix in name" {
create_version "2.7.6"
cat > ".python-version" <<<"python-2.7.6"

View File

@@ -36,3 +36,37 @@ setup() {
run pyenv-version
assert_success "3.3.3 (set by ${PYENV_ROOT}/version)"
}
@test "set by PYENV_VERSION, one missing" {
create_version "3.3.3"
PYENV_VERSION=3.3.3:1.2 run pyenv-version
assert_failure
assert_output <<OUT
pyenv: version \`1.2' is not installed
3.3.3 (set by PYENV_VERSION environment variable)
OUT
}
@test "set by PYENV_VERSION, two missing" {
create_version "3.3.3"
PYENV_VERSION=3.4.2:3.3.3:1.2 run pyenv-version
assert_failure
assert_output <<OUT
pyenv: version \`3.4.2' is not installed
pyenv: version \`1.2' is not installed
3.3.3 (set by PYENV_VERSION environment variable)
OUT
}
pyenv-version-without-stderr() {
pyenv-version 2>/dev/null
}
@test "set by PYENV_VERSION, one missing (stderr filtered)" {
create_version "3.3.3"
PYENV_VERSION=3.4.2:3.3.3 run pyenv-version-without-stderr
assert_failure
assert_output <<OUT
3.3.3 (set by PYENV_VERSION environment variable)
OUT
}