From f966c97adf875ba739442984e852cdeca30e6208 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Wed, 15 Apr 2026 12:25:18 -0400 Subject: [PATCH] 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. --- test/virtualenvs.bats | 114 +++++++++++++++++++++++++++++++++--------- 1 file changed, 90 insertions(+), 24 deletions(-) diff --git a/test/virtualenvs.bats b/test/virtualenvs.bats index e4dd10a..8863c94 100644 --- a/test/virtualenvs.bats +++ b/test/virtualenvs.bats @@ -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 < ${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 < ${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 < ${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 <