tests: refactor: migrate to newly-added create_stub()

This commit is contained in:
Ivan Pozdeev 2025-12-20 09:31:05 +03:00 committed by Ivan Pozdeev
parent 7418835908
commit 6113214f65
No known key found for this signature in database
GPG Key ID: FB6A628DCF06DCD7
2 changed files with 12 additions and 34 deletions

View File

@ -2,10 +2,6 @@
load test_helper
_setup() {
export PATH="${PYENV_TEST_DIR}/bin:$PATH"
}
@test "creates shims and versions directories" {
assert [ ! -d "${PYENV_ROOT}/shims" ]
assert [ ! -d "${PYENV_ROOT}/versions" ]
@ -171,16 +167,14 @@ echo "\$PATH"
}
@test "outputs sh-compatible case syntax" {
create_path_executable pyenv-commands <<!
#!$BASH
create_stub pyenv-commands <<!
echo -e 'activate\ndeactivate\nrehash\nshell'
!
run pyenv-init - bash
assert_success
assert_line ' activate|deactivate|rehash|shell)'
create_path_executable pyenv-commands <<!
#!$BASH
create_stub pyenv-commands <<!
echo
!
run pyenv-init - bash

View File

@ -2,13 +2,8 @@
load test_helper
_setup() {
export PATH="${PYENV_TEST_DIR}/bin:$PATH"
}
@test "read from installed" {
create_path_executable pyenv-versions <<!
#!$BASH
create_stub pyenv-versions <<!
echo 4.5.6
!
run pyenv-latest 4
@ -19,8 +14,7 @@ echo 4.5.6
}
@test "read from known" {
create_path_executable python-build <<!
#!$BASH
create_stub python-build <<!
echo 4.5.6
!
run pyenv-latest -k 4
@ -31,8 +25,7 @@ echo 4.5.6
}
@test "installed version not found" {
create_path_executable pyenv-versions <<!
#!$BASH
create_stub pyenv-versions <<!
echo 3.5.6
echo 3.10.8
!
@ -44,8 +37,7 @@ pyenv: no installed versions match the prefix \`3.8'
}
@test "known version not found" {
create_path_executable python-build <<!
#!$BASH
create_stub python-build <<!
echo 3.5.6
echo 3.10.8
!
@ -57,8 +49,7 @@ pyenv: no known versions match the prefix \`3.8'
}
@test "complete name resolves to itself" {
create_path_executable pyenv-versions <<!
#!$BASH
create_stub pyenv-versions <<!
echo foo
echo foo.bar
!
@ -72,8 +63,7 @@ foo
}
@test "sort CPython" {
create_path_executable pyenv-versions <<!
#!$BASH
create_stub pyenv-versions <<!
echo 2.7.18
echo 3.5.6
echo 3.10.8
@ -87,8 +77,7 @@ echo 3.10.6
}
@test "ignores rolling releases, branch tips, alternative srcs, prereleases, virtualenvs; 't' versions if prefix without 't'" {
create_path_executable pyenv-versions <<!
#!$BASH
create_stub pyenv-versions <<!
echo 3.8.5-dev
echo 3.8.5-src
echo 3.8.5-latest
@ -109,8 +98,7 @@ echo 3.8.1/envs/foo
}
@test "resolves to a 't' version if prefix has 't'" {
create_path_executable pyenv-versions <<!
#!$BASH
create_stub pyenv-versions <<!
echo 3.13.2t
echo 3.13.5
echo 3.13.5t
@ -124,9 +112,7 @@ echo 3.14.6
}
@test "falls back to argument with -b" {
create_path_executable pyenv-versions <<!
#!$BASH
!
create_stub pyenv-versions
run pyenv-latest -b nonexistent
assert_failure
assert_output <<!
@ -135,9 +121,7 @@ nonexistent
}
@test "falls back to argument and succeeds with -f" {
create_path_executable pyenv-versions <<!
#!$BASH
!
create_stub pyenv-versions
run pyenv-latest -f nonexistent
assert_success
assert_output <<!