Kaynağa Gözat

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

pull/3375/head
Ivan Pozdeev 6 ay önce
işlemeyi yapan: Ivan Pozdeev
ebeveyn
işleme
6113214f65
Veri tabanında bu imza için bilinen anahtar bulunamadı GPG Anahtar Kimliği: FB6A628DCF06DCD7
2 değiştirilmiş dosya ile 12 ekleme ve 34 silme
  1. +2
    -8
      test/init.bats
  2. +10
    -26
      test/latest.bats

+ 2
- 8
test/init.bats Dosyayı Görüntüle

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

+ 10
- 26
test/latest.bats Dosyayı Görüntüle

@ -2,13 +2,8 @@
load test_helper load test_helper
_setup() {
export PATH="${PYENV_TEST_DIR}/bin:$PATH"
}
@test "read from installed" { @test "read from installed" {
create_path_executable pyenv-versions <<!
#!$BASH
create_stub pyenv-versions <<!
echo 4.5.6 echo 4.5.6
! !
run pyenv-latest 4 run pyenv-latest 4
@ -19,8 +14,7 @@ echo 4.5.6
} }
@test "read from known" { @test "read from known" {
create_path_executable python-build <<!
#!$BASH
create_stub python-build <<!
echo 4.5.6 echo 4.5.6
! !
run pyenv-latest -k 4 run pyenv-latest -k 4
@ -31,8 +25,7 @@ echo 4.5.6
} }
@test "installed version not found" { @test "installed version not found" {
create_path_executable pyenv-versions <<!
#!$BASH
create_stub pyenv-versions <<!
echo 3.5.6 echo 3.5.6
echo 3.10.8 echo 3.10.8
! !
@ -44,8 +37,7 @@ pyenv: no installed versions match the prefix \`3.8'
} }
@test "known version not found" { @test "known version not found" {
create_path_executable python-build <<!
#!$BASH
create_stub python-build <<!
echo 3.5.6 echo 3.5.6
echo 3.10.8 echo 3.10.8
! !
@ -57,8 +49,7 @@ pyenv: no known versions match the prefix \`3.8'
} }
@test "complete name resolves to itself" { @test "complete name resolves to itself" {
create_path_executable pyenv-versions <<!
#!$BASH
create_stub pyenv-versions <<!
echo foo echo foo
echo foo.bar echo foo.bar
! !
@ -72,8 +63,7 @@ foo
} }
@test "sort CPython" { @test "sort CPython" {
create_path_executable pyenv-versions <<!
#!$BASH
create_stub pyenv-versions <<!
echo 2.7.18 echo 2.7.18
echo 3.5.6 echo 3.5.6
echo 3.10.8 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'" { @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-dev
echo 3.8.5-src echo 3.8.5-src
echo 3.8.5-latest 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'" { @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.2t
echo 3.13.5 echo 3.13.5
echo 3.13.5t echo 3.13.5t
@ -124,9 +112,7 @@ echo 3.14.6
} }
@test "falls back to argument with -b" { @test "falls back to argument with -b" {
create_path_executable pyenv-versions <<!
#!$BASH
!
create_stub pyenv-versions
run pyenv-latest -b nonexistent run pyenv-latest -b nonexistent
assert_failure assert_failure
assert_output <<! assert_output <<!
@ -135,9 +121,7 @@ nonexistent
} }
@test "falls back to argument and succeeds with -f" { @test "falls back to argument and succeeds with -f" {
create_path_executable pyenv-versions <<!
#!$BASH
!
create_stub pyenv-versions
run pyenv-latest -f nonexistent run pyenv-latest -f nonexistent
assert_success assert_success
assert_output <<! assert_output <<!

Yükleniyor…
İptal
Kaydet