Modify applications and versions for Python

This commit is contained in:
Yamashita Yuu 2014-01-03 04:38:29 +09:00
parent 3dd9332eee
commit 319721b380
10 changed files with 145 additions and 145 deletions

View file

@ -15,22 +15,22 @@ create_executable() {
}
@test "fails with invalid version" {
export PYENV_VERSION="2.0"
export PYENV_VERSION="3.4"
run pyenv-exec python -v
assert_failure "pyenv: version \`2.0' is not installed"
assert_failure "pyenv: version \`3.4' is not installed"
}
@test "completes with names of executables" {
export PYENV_VERSION="2.0"
export PYENV_VERSION="3.4"
create_executable "fab" "#!/bin/sh"
create_executable "python" "#!/bin/sh"
create_executable "rake" "#!/bin/sh"
pyenv-rehash
run pyenv-completions exec
assert_success
assert_output <<OUT
fab
python
rake
OUT
}
@ -60,7 +60,7 @@ SH
}
@test "forwards all arguments" {
export PYENV_VERSION="2.0"
export PYENV_VERSION="3.4"
create_executable "python" <<SH
#!$BASH
echo \$0
@ -73,7 +73,7 @@ SH
run pyenv-exec python -w "/path to/python script.rb" -- extra args
assert_success
assert_output <<OUT
${PYENV_ROOT}/versions/2.0/bin/python
${PYENV_ROOT}/versions/3.4/bin/python
-w
/path to/python script.rb
--
@ -83,7 +83,7 @@ OUT
}
@test "supports python -S <cmd>" {
export PYENV_VERSION="2.0"
export PYENV_VERSION="3.4"
# emulate `python -S' behavior
create_executable "python" <<SH
@ -98,16 +98,16 @@ if [[ \$1 == "-S"* ]]; then
exit 1
fi
else
echo 'python 2.0 (pyenv test)'
echo 'python 3.4 (pyenv test)'
fi
SH
create_executable "rake" <<SH
create_executable "fab" <<SH
#!/usr/bin/env python
echo hello rake
echo hello fab
SH
pyenv-rehash
run python -S rake
assert_success "hello rake"
run python -S fab
assert_success "hello fab"
}

View file

@ -26,10 +26,10 @@ setup() {
}
@test "local .python-version has precedence over .pyenv-version" {
echo "1.8" > .pyenv-version
echo "2.0" > .python-version
echo "2.7" > .pyenv-version
echo "3.4" > .python-version
run pyenv-local
assert_success "2.0"
assert_success "3.4"
}
@test "ignores version in parent directory" {
@ -42,7 +42,7 @@ setup() {
@test "ignores PYENV_DIR" {
echo "1.2.3" > .python-version
mkdir -p "$HOME"
echo "2.0-home" > "${HOME}/.python-version"
echo "3.4-home" > "${HOME}/.python-version"
PYENV_DIR="$HOME" run pyenv-local
assert_success "1.2.3"
}
@ -65,27 +65,27 @@ setup() {
}
@test "renames .pyenv-version to .python-version" {
echo "1.8.7" > .pyenv-version
mkdir -p "${PYENV_ROOT}/versions/1.9.3"
echo "2.7.6" > .pyenv-version
mkdir -p "${PYENV_ROOT}/versions/3.3.3"
run pyenv-local
assert_success "1.8.7"
run pyenv-local "1.9.3"
assert_success "2.7.6"
run pyenv-local "3.3.3"
assert_success
assert_output <<OUT
pyenv: removed existing \`.pyenv-version' file and migrated
local version specification to \`.python-version' file
OUT
assert [ ! -e .pyenv-version ]
assert [ "$(cat .python-version)" = "1.9.3" ]
assert [ "$(cat .python-version)" = "3.3.3" ]
}
@test "doesn't rename .pyenv-version if changing the version failed" {
echo "1.8.7" > .pyenv-version
assert [ ! -e "${PYENV_ROOT}/versions/1.9.3" ]
run pyenv-local "1.9.3"
assert_failure "pyenv: version \`1.9.3' not installed"
echo "2.7.6" > .pyenv-version
assert [ ! -e "${PYENV_ROOT}/versions/3.3.3" ]
run pyenv-local "3.3.3"
assert_failure "pyenv: version \`3.3.3' not installed"
assert [ ! -e .python-version ]
assert [ "$(cat .pyenv-version)" = "1.8.7" ]
assert [ "$(cat .pyenv-version)" = "2.7.6" ]
}
@test "unsets local version" {

View file

@ -32,14 +32,14 @@ create_executable() {
}
@test "creates shims" {
create_executable "1.8" "python"
create_executable "1.8" "rake"
create_executable "2.0" "python"
create_executable "2.0" "rspec"
create_executable "2.7" "python"
create_executable "2.7" "fab"
create_executable "3.4" "python"
create_executable "3.4" "py.test"
assert [ ! -e "${PYENV_ROOT}/shims/fab" ]
assert [ ! -e "${PYENV_ROOT}/shims/python" ]
assert [ ! -e "${PYENV_ROOT}/shims/rake" ]
assert [ ! -e "${PYENV_ROOT}/shims/rspec" ]
assert [ ! -e "${PYENV_ROOT}/shims/py.test" ]
run pyenv-rehash
assert_success ""
@ -47,9 +47,9 @@ create_executable() {
run ls "${PYENV_ROOT}/shims"
assert_success
assert_output <<OUT
fab
py.test
python
rake
rspec
OUT
}
@ -58,8 +58,8 @@ OUT
touch "${PYENV_ROOT}/shims/oldshim1"
chmod +x "${PYENV_ROOT}/shims/oldshim1"
create_executable "2.0" "rake"
create_executable "2.0" "python"
create_executable "3.4" "fab"
create_executable "3.4" "python"
run pyenv-rehash
assert_success ""
@ -69,10 +69,10 @@ OUT
@test "binary install locations containing spaces" {
create_executable "dirname1 p247" "python"
create_executable "dirname2 preview1" "rspec"
create_executable "dirname2 preview1" "py.test"
assert [ ! -e "${PYENV_ROOT}/shims/python" ]
assert [ ! -e "${PYENV_ROOT}/shims/rspec" ]
assert [ ! -e "${PYENV_ROOT}/shims/py.test" ]
run pyenv-rehash
assert_success ""
@ -80,8 +80,8 @@ OUT
run ls "${PYENV_ROOT}/shims"
assert_success
assert_output <<OUT
py.test
python
rspec
OUT
}
@ -100,14 +100,14 @@ SH
}
@test "sh-rehash in bash" {
create_executable "2.0" "python"
create_executable "3.4" "python"
PYENV_SHELL=bash run pyenv-sh-rehash
assert_success "hash -r 2>/dev/null || true"
assert [ -x "${PYENV_ROOT}/shims/python" ]
}
@test "sh-rehash in fish" {
create_executable "2.0" "python"
create_executable "3.4" "python"
PYENV_SHELL=fish run pyenv-sh-rehash
assert_success ""
assert [ -x "${PYENV_ROOT}/shims/python" ]

View file

@ -24,43 +24,43 @@ setup() {
}
@test "reads simple version file" {
cat > my-version <<<"1.9.3"
cat > my-version <<<"3.3.3"
run pyenv-version-file-read my-version
assert_success "1.9.3"
assert_success "3.3.3"
}
@test "ignores leading spaces" {
cat > my-version <<<" 1.9.3"
cat > my-version <<<" 3.3.3"
run pyenv-version-file-read my-version
assert_success "1.9.3"
assert_success "3.3.3"
}
@test "reads only the first word from file" {
cat > my-version <<<"1.9.3-p194@tag 1.8.7 hi"
cat > my-version <<<"3.3.3-p194@tag 2.7.6 hi"
run pyenv-version-file-read my-version
assert_success "1.9.3-p194@tag:1.8.7:hi"
assert_success "3.3.3-p194@tag:2.7.6:hi"
}
@test "loads only the first line in file" {
cat > my-version <<IN
1.8.7 one
1.9.3 two
2.7.6 one
3.3.3 two
IN
run pyenv-version-file-read my-version
assert_success "1.8.7:one:1.9.3:two"
assert_success "2.7.6:one:3.3.3:two"
}
@test "ignores leading blank lines" {
cat > my-version <<IN
1.9.3
3.3.3
IN
run pyenv-version-file-read my-version
assert_success "1.9.3"
assert_success "3.3.3"
}
@test "handles the file with no trailing newline" {
echo -n "1.8.7" > my-version
echo -n "2.7.6" > my-version
run pyenv-version-file-read my-version
assert_success "1.8.7"
assert_success "2.7.6"
}

View file

@ -16,15 +16,15 @@ setup() {
@test "setting nonexistent version fails" {
assert [ ! -e ".python-version" ]
run pyenv-version-file-write ".python-version" "1.8.7"
assert_failure "pyenv: version \`1.8.7' not installed"
run pyenv-version-file-write ".python-version" "2.7.6"
assert_failure "pyenv: version \`2.7.6' not installed"
assert [ ! -e ".python-version" ]
}
@test "writes value to arbitrary file" {
mkdir -p "${PYENV_ROOT}/versions/1.8.7"
mkdir -p "${PYENV_ROOT}/versions/2.7.6"
assert [ ! -e "my-version" ]
run pyenv-version-file-write "${PWD}/my-version" "1.8.7"
run pyenv-version-file-write "${PWD}/my-version" "2.7.6"
assert_success ""
assert [ "$(cat my-version)" = "1.8.7" ]
assert [ "$(cat my-version)" = "2.7.6" ]
}

View file

@ -23,28 +23,28 @@ setup() {
}
@test "PYENV_VERSION has precedence over local" {
create_version "1.8.7"
create_version "1.9.3"
create_version "2.7.6"
create_version "3.3.3"
cat > ".python-version" <<<"1.8.7"
cat > ".python-version" <<<"2.7.6"
run pyenv-version-name
assert_success "1.8.7"
assert_success "2.7.6"
PYENV_VERSION=1.9.3 run pyenv-version-name
assert_success "1.9.3"
PYENV_VERSION=3.3.3 run pyenv-version-name
assert_success "3.3.3"
}
@test "local file has precedence over global" {
create_version "1.8.7"
create_version "1.9.3"
create_version "2.7.6"
create_version "3.3.3"
cat > "${PYENV_ROOT}/version" <<<"1.8.7"
cat > "${PYENV_ROOT}/version" <<<"2.7.6"
run pyenv-version-name
assert_success "1.8.7"
assert_success "2.7.6"
cat > ".python-version" <<<"1.9.3"
cat > ".python-version" <<<"3.3.3"
run pyenv-version-name
assert_success "1.9.3"
assert_success "3.3.3"
}
@test "missing version" {
@ -53,13 +53,13 @@ setup() {
}
@test "version with prefix in name" {
create_version "1.8.7"
cat > ".python-version" <<<"python-1.8.7"
create_version "2.7.6"
cat > ".python-version" <<<"python-2.7.6"
run pyenv-version-name
assert_success
assert_output <<OUT
warning: ignoring extraneous \`python-' prefix in version \`python-1.8.7'
warning: ignoring extraneous \`python-' prefix in version \`python-2.7.6'
(set by ${PWD}/.python-version)
1.8.7
2.7.6
OUT
}

View file

@ -18,21 +18,21 @@ setup() {
}
@test "set by PYENV_VERSION" {
create_version "1.9.3"
PYENV_VERSION=1.9.3 run pyenv-version
assert_success "1.9.3 (set by PYENV_VERSION environment variable)"
create_version "3.3.3"
PYENV_VERSION=3.3.3 run pyenv-version
assert_success "3.3.3 (set by PYENV_VERSION environment variable)"
}
@test "set by local file" {
create_version "1.9.3"
cat > ".python-version" <<<"1.9.3"
create_version "3.3.3"
cat > ".python-version" <<<"3.3.3"
run pyenv-version
assert_success "1.9.3 (set by ${PWD}/.python-version)"
assert_success "3.3.3 (set by ${PWD}/.python-version)"
}
@test "set by global file" {
create_version "1.9.3"
cat > "${PYENV_ROOT}/version" <<<"1.9.3"
create_version "3.3.3"
cat > "${PYENV_ROOT}/version" <<<"3.3.3"
run pyenv-version
assert_success "1.9.3 (set by ${PYENV_ROOT}/version)"
assert_success "3.3.3 (set by ${PYENV_ROOT}/version)"
}

View file

@ -32,84 +32,84 @@ stub_system_python() {
@test "single version installed" {
stub_system_python
create_version "1.9"
create_version "3.3"
run pyenv-versions
assert_success
assert_output <<OUT
* system (set by ${PYENV_ROOT}/version)
1.9
3.3
OUT
}
@test "single version bare" {
create_version "1.9"
create_version "3.3"
run pyenv-versions --bare
assert_success "1.9"
assert_success "3.3"
}
@test "multiple versions" {
stub_system_python
create_version "1.8.7"
create_version "1.9.3"
create_version "2.0.0"
create_version "2.7.6"
create_version "3.3.3"
create_version "3.4.0"
run pyenv-versions
assert_success
assert_output <<OUT
* system (set by ${PYENV_ROOT}/version)
1.8.7
1.9.3
2.0.0
2.7.6
3.3.3
3.4.0
OUT
}
@test "indicates current version" {
stub_system_python
create_version "1.9.3"
create_version "2.0.0"
PYENV_VERSION=1.9.3 run pyenv-versions
create_version "3.3.3"
create_version "3.4.0"
PYENV_VERSION=3.3.3 run pyenv-versions
assert_success
assert_output <<OUT
system
* 1.9.3 (set by PYENV_VERSION environment variable)
2.0.0
* 3.3.3 (set by PYENV_VERSION environment variable)
3.4.0
OUT
}
@test "bare doesn't indicate current version" {
create_version "1.9.3"
create_version "2.0.0"
PYENV_VERSION=1.9.3 run pyenv-versions --bare
create_version "3.3.3"
create_version "3.4.0"
PYENV_VERSION=3.3.3 run pyenv-versions --bare
assert_success
assert_output <<OUT
1.9.3
2.0.0
3.3.3
3.4.0
OUT
}
@test "globally selected version" {
stub_system_python
create_version "1.9.3"
create_version "2.0.0"
cat > "${PYENV_ROOT}/version" <<<"1.9.3"
create_version "3.3.3"
create_version "3.4.0"
cat > "${PYENV_ROOT}/version" <<<"3.3.3"
run pyenv-versions
assert_success
assert_output <<OUT
system
* 1.9.3 (set by ${PYENV_ROOT}/version)
2.0.0
* 3.3.3 (set by ${PYENV_ROOT}/version)
3.4.0
OUT
}
@test "per-project version" {
stub_system_python
create_version "1.9.3"
create_version "2.0.0"
cat > ".python-version" <<<"1.9.3"
create_version "3.3.3"
create_version "3.4.0"
cat > ".python-version" <<<"3.3.3"
run pyenv-versions
assert_success
assert_output <<OUT
system
* 1.9.3 (set by ${PYENV_TEST_DIR}/.python-version)
2.0.0
* 3.3.3 (set by ${PYENV_TEST_DIR}/.python-version)
3.4.0
OUT
}

View file

@ -10,21 +10,21 @@ create_executable() {
}
@test "finds versions where present" {
create_executable "1.8" "python"
create_executable "1.8" "rake"
create_executable "2.0" "python"
create_executable "2.0" "rspec"
create_executable "2.7" "python"
create_executable "2.7" "fab"
create_executable "3.4" "python"
create_executable "3.4" "py.test"
run pyenv-whence python
assert_success
assert_output <<OUT
1.8
2.0
2.7
3.4
OUT
run pyenv-whence rake
assert_success "1.8"
run pyenv-whence fab
assert_success "2.7"
run pyenv-whence rspec
assert_success "2.0"
run pyenv-whence py.test
assert_success "3.4"
}

View file

@ -13,14 +13,14 @@ create_executable() {
}
@test "outputs path to executable" {
create_executable "1.8" "python"
create_executable "2.0" "rspec"
create_executable "2.7" "python"
create_executable "3.4" "py.test"
PYENV_VERSION=1.8 run pyenv-which python
assert_success "${PYENV_ROOT}/versions/1.8/bin/python"
PYENV_VERSION=2.7 run pyenv-which python
assert_success "${PYENV_ROOT}/versions/2.7/bin/python"
PYENV_VERSION=2.0 run pyenv-which rspec
assert_success "${PYENV_ROOT}/versions/2.0/bin/rspec"
PYENV_VERSION=3.4 run pyenv-which py.test
assert_success "${PYENV_ROOT}/versions/3.4/bin/py.test"
}
@test "searches PATH for system version" {
@ -32,30 +32,30 @@ create_executable() {
}
@test "version not installed" {
create_executable "2.0" "rspec"
PYENV_VERSION=1.9 run pyenv-which rspec
assert_failure "pyenv: version \`1.9' is not installed"
create_executable "3.4" "py.test"
PYENV_VERSION=3.3 run pyenv-which py.test
assert_failure "pyenv: version \`3.3' is not installed"
}
@test "no executable found" {
create_executable "1.8" "rspec"
PYENV_VERSION=1.8 run pyenv-which rake
assert_failure "pyenv: rake: command not found"
create_executable "2.7" "py.test"
PYENV_VERSION=2.7 run pyenv-which fab
assert_failure "pyenv: fab: command not found"
}
@test "executable found in other versions" {
create_executable "1.8" "python"
create_executable "1.9" "rspec"
create_executable "2.0" "rspec"
create_executable "2.7" "python"
create_executable "3.3" "py.test"
create_executable "3.4" "py.test"
PYENV_VERSION=1.8 run pyenv-which rspec
PYENV_VERSION=2.7 run pyenv-which py.test
assert_failure
assert_output <<OUT
pyenv: rspec: command not found
pyenv: py.test: command not found
The \`rspec' command exists in these Python versions:
1.9
2.0
The \`py.test' command exists in these Python versions:
3.3
3.4
OUT
}