mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2026-09-10 15:26:23 -04:00
Update tests and add more test cases
Update the existing tests based on new behavior/output format. Add additional tests to cover scenarios that were not previously tested.
This commit is contained in:
parent
f9d1686cfa
commit
f966c97adf
|
|
@ -10,12 +10,8 @@ setup() {
|
|||
ln -s "${PYENV_ROOT}/versions/3.3.3/envs/venv33" "${PYENV_ROOT}/versions/venv33"
|
||||
}
|
||||
|
||||
@test "list virtual environments only" {
|
||||
@test "list virtual environments" {
|
||||
stub pyenv-version-name ": echo system"
|
||||
stub pyenv-virtualenv-prefix "2.7.6 : false"
|
||||
stub pyenv-virtualenv-prefix "3.3.3 : false"
|
||||
stub pyenv-virtualenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/2.7.6\""
|
||||
stub pyenv-virtualenv-prefix "venv33 : echo \"${PYENV_ROOT}/versions/3.3.3\""
|
||||
|
||||
run pyenv-virtualenvs
|
||||
|
||||
|
|
@ -23,44 +19,114 @@ setup() {
|
|||
assert_output <<OUT
|
||||
2.7.6/envs/venv27
|
||||
3.3.3/envs/venv33
|
||||
venv27 --> ${PYENV_ROOT}/versions/2.7.6/envs/venv27
|
||||
venv33 --> ${PYENV_ROOT}/versions/3.3.3/envs/venv33
|
||||
OUT
|
||||
|
||||
# unstub pyenv-version-name
|
||||
# unstub pyenv-virtualenv-prefix
|
||||
unstub pyenv-version-name
|
||||
}
|
||||
|
||||
@test "list virtual environments with hit prefix" {
|
||||
stub pyenv-version-name ": echo venv33"
|
||||
stub pyenv-virtualenv-prefix "2.7.6 : false"
|
||||
stub pyenv-virtualenv-prefix "3.3.3 : false"
|
||||
stub pyenv-virtualenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/2.7.6\""
|
||||
stub pyenv-virtualenv-prefix "venv33 : echo \"${PYENV_ROOT}/versions/3.3.3\""
|
||||
stub pyenv-version-name ": echo 3.3.3/envs/venv33"
|
||||
stub pyenv-version-origin ": echo PYENV_VERSION"
|
||||
|
||||
run pyenv-virtualenvs
|
||||
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
2.7.6/envs/venv27
|
||||
* 3.3.3/envs/venv33
|
||||
* 3.3.3/envs/venv33 (set by PYENV_VERSION)
|
||||
venv27 --> ${PYENV_ROOT}/versions/2.7.6/envs/venv27
|
||||
venv33 --> ${PYENV_ROOT}/versions/3.3.3/envs/venv33
|
||||
OUT
|
||||
|
||||
# unstub pyenv-version-name
|
||||
# unstub pyenv-virtualenv-prefix
|
||||
unstub pyenv-version-name
|
||||
unstub pyenv-version-origin
|
||||
}
|
||||
|
||||
@test "list virtual environments with --bare" {
|
||||
stub pyenv-virtualenv-prefix "2.7.6 : false"
|
||||
stub pyenv-virtualenv-prefix "3.3.3 : false"
|
||||
stub pyenv-virtualenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/2.7.6\""
|
||||
stub pyenv-virtualenv-prefix "venv33 : echo \"${PYENV_ROOT}/versions/3.3.3\""
|
||||
|
||||
run pyenv-virtualenvs --bare --only-aliases
|
||||
@test "list bare virtual environments" {
|
||||
run pyenv-virtualenvs --bare
|
||||
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
2.7.6/envs/venv27
|
||||
3.3.3/envs/venv33
|
||||
venv27
|
||||
venv33
|
||||
OUT
|
||||
|
||||
unstub pyenv-virtualenv-prefix
|
||||
}
|
||||
|
||||
@test "list bare virtual environments without aliases" {
|
||||
run pyenv-virtualenvs --bare --skip-aliases
|
||||
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
2.7.6/envs/venv27
|
||||
3.3.3/envs/venv33
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "list virtual environments without aliases" {
|
||||
stub pyenv-version-name ": echo system"
|
||||
|
||||
run pyenv-virtualenvs --skip-aliases
|
||||
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
2.7.6/envs/venv27
|
||||
3.3.3/envs/venv33
|
||||
OUT
|
||||
|
||||
unstub pyenv-version-name
|
||||
}
|
||||
|
||||
@test "hit prefix matches alias version name" {
|
||||
stub pyenv-version-name ": echo venv27"
|
||||
stub pyenv-version-origin ": echo PYENV_VERSION"
|
||||
|
||||
run pyenv-virtualenvs
|
||||
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
2.7.6/envs/venv27
|
||||
3.3.3/envs/venv33
|
||||
* venv27 --> ${PYENV_ROOT}/versions/2.7.6/envs/venv27 (set by PYENV_VERSION)
|
||||
venv33 --> ${PYENV_ROOT}/versions/3.3.3/envs/venv33
|
||||
OUT
|
||||
|
||||
unstub pyenv-version-name
|
||||
unstub pyenv-version-origin
|
||||
}
|
||||
|
||||
@test "no virtualenvs warning" {
|
||||
rm -rf "${PYENV_ROOT}/versions"
|
||||
mkdir -p "${PYENV_ROOT}/versions"
|
||||
stub pyenv-version-name ": echo system"
|
||||
|
||||
run pyenv-virtualenvs
|
||||
|
||||
assert_failure
|
||||
assert_output "Warning: no Python virtualenv detected on the system"
|
||||
|
||||
unstub pyenv-version-name
|
||||
}
|
||||
|
||||
@test "no warning with --bare and no virtualenvs" {
|
||||
rm -rf "${PYENV_ROOT}/versions"
|
||||
mkdir -p "${PYENV_ROOT}/versions"
|
||||
|
||||
run pyenv-virtualenvs --bare
|
||||
|
||||
assert_success
|
||||
assert_output ""
|
||||
}
|
||||
|
||||
@test "completions output" {
|
||||
run pyenv-virtualenvs --complete
|
||||
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
--bare
|
||||
--skip-aliases
|
||||
OUT
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue