mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-12 13:33:52 -05:00
Display information on automatic (de)?activation
This commit is contained in:
@@ -27,6 +27,27 @@ source "${PYENV_ROOT}/versions/venv/bin/activate";
|
||||
EOS
|
||||
}
|
||||
|
||||
@test "activate virtualenv from current version (verbose)" {
|
||||
export PYENV_VIRTUALENV_INIT=1
|
||||
|
||||
stub pyenv-version-name "echo venv"
|
||||
stub pyenv-virtualenv-prefix "venv : echo \"${PYENV_ROOT}/versions/venv\""
|
||||
stub pyenv-prefix "venv : echo \"${PYENV_ROOT}/versions/venv\""
|
||||
|
||||
PYENV_SHELL="bash" PYENV_VERSION="venv" run pyenv-sh-activate --verbose
|
||||
|
||||
unstub pyenv-version-name
|
||||
unstub pyenv-virtualenv-prefix
|
||||
unstub pyenv-prefix
|
||||
|
||||
assert_success
|
||||
assert_output <<EOS
|
||||
pyenv-virtualenv: activate venv
|
||||
unset PYENV_DEACTIVATE;
|
||||
source "${PYENV_ROOT}/versions/venv/bin/activate";
|
||||
EOS
|
||||
}
|
||||
|
||||
@test "activate virtualenv from current version (without pyenv-virtualenv-init)" {
|
||||
export PYENV_VIRTUALENV_INIT=
|
||||
|
||||
|
||||
@@ -8,13 +8,33 @@ setup() {
|
||||
|
||||
@test "deactivate virtualenv" {
|
||||
export PYENV_VIRTUALENV_INIT=1
|
||||
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
|
||||
|
||||
PYENV_SHELL="bash" run pyenv-sh-deactivate
|
||||
|
||||
assert_success
|
||||
assert_output <<EOS
|
||||
if declare -f deactivate 1>/dev/null 2>&1; then
|
||||
export PYENV_DEACTIVATE="\$VIRTUAL_ENV";
|
||||
export PYENV_DEACTIVATE="$VIRTUAL_ENV";
|
||||
deactivate;
|
||||
else
|
||||
echo "pyenv-virtualenv: no virtualenv has been activated." 1>&2;
|
||||
false;
|
||||
fi;
|
||||
EOS
|
||||
}
|
||||
|
||||
@test "deactivate virtualenv (verbose)" {
|
||||
export PYENV_VIRTUALENV_INIT=1
|
||||
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
|
||||
|
||||
PYENV_SHELL="bash" run pyenv-sh-deactivate --verbose
|
||||
|
||||
assert_success
|
||||
assert_output <<EOS
|
||||
if declare -f deactivate 1>/dev/null 2>&1; then
|
||||
echo "pyenv-virtualenv: deactivate venv" 1>&2;
|
||||
export PYENV_DEACTIVATE="$VIRTUAL_ENV";
|
||||
deactivate;
|
||||
else
|
||||
echo "pyenv-virtualenv: no virtualenv has been activated." 1>&2;
|
||||
@@ -25,13 +45,14 @@ EOS
|
||||
|
||||
@test "deactivate virtualenv (no-error)" {
|
||||
export PYENV_VIRTUALENV_INIT=1
|
||||
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
|
||||
|
||||
PYENV_SHELL="bash" run pyenv-sh-deactivate --no-error
|
||||
|
||||
assert_success
|
||||
assert_output <<EOS
|
||||
if declare -f deactivate 1>/dev/null 2>&1; then
|
||||
export PYENV_DEACTIVATE="\$VIRTUAL_ENV";
|
||||
export PYENV_DEACTIVATE="$VIRTUAL_ENV";
|
||||
deactivate;
|
||||
else
|
||||
false;
|
||||
@@ -39,8 +60,9 @@ fi;
|
||||
EOS
|
||||
}
|
||||
|
||||
@test "deactivate virtualenv (w/o pyenv-virtualenv-init)" {
|
||||
@test "deactivate virtualenv (without pyenv-virtualenv-init)" {
|
||||
export PYENV_VIRTUALENV_INIT=
|
||||
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
|
||||
|
||||
PYENV_SHELL="bash" run pyenv-sh-deactivate
|
||||
|
||||
@@ -48,7 +70,7 @@ EOS
|
||||
assert_output <<EOS
|
||||
if declare -f deactivate 1>/dev/null 2>&1; then
|
||||
pyenv shell --unset;
|
||||
export PYENV_DEACTIVATE="\$VIRTUAL_ENV";
|
||||
export PYENV_DEACTIVATE="$VIRTUAL_ENV";
|
||||
deactivate;
|
||||
else
|
||||
echo "pyenv-virtualenv: no virtualenv has been activated." 1>&2;
|
||||
@@ -57,8 +79,9 @@ fi;
|
||||
EOS
|
||||
}
|
||||
|
||||
@test "deactivate virtualenv (w/o pyenv-virtualenv-init) (no-error)" {
|
||||
@test "deactivate virtualenv (without pyenv-virtualenv-init) (no-error)" {
|
||||
export PYENV_VIRTUALENV_INIT=
|
||||
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
|
||||
|
||||
PYENV_SHELL="bash" run pyenv-sh-deactivate --no-error
|
||||
|
||||
@@ -66,7 +89,7 @@ EOS
|
||||
assert_output <<EOS
|
||||
if declare -f deactivate 1>/dev/null 2>&1; then
|
||||
pyenv shell --unset;
|
||||
export PYENV_DEACTIVATE="\$VIRTUAL_ENV";
|
||||
export PYENV_DEACTIVATE="$VIRTUAL_ENV";
|
||||
deactivate;
|
||||
else
|
||||
false;
|
||||
@@ -76,13 +99,14 @@ EOS
|
||||
|
||||
@test "deactivate virtualenv (fish)" {
|
||||
export PYENV_VIRTUALENV_INIT=1
|
||||
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
|
||||
|
||||
PYENV_SHELL="fish" run pyenv-sh-deactivate
|
||||
|
||||
assert_success
|
||||
assert_output <<EOS
|
||||
if functions -q deactivate
|
||||
setenv PYENV_DEACTIVATE "\$VIRTUAL_ENV";
|
||||
setenv PYENV_DEACTIVATE "$VIRTUAL_ENV";
|
||||
deactivate;
|
||||
else;
|
||||
echo "pyenv-virtualenv: no virtualenv has been activated." 1>&2;
|
||||
@@ -93,13 +117,14 @@ EOS
|
||||
|
||||
@test "deactivate virtualenv (fish) (no-error)" {
|
||||
export PYENV_VIRTUALENV_INIT=1
|
||||
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
|
||||
|
||||
PYENV_SHELL="fish" run pyenv-sh-deactivate --no-error
|
||||
|
||||
assert_success
|
||||
assert_output <<EOS
|
||||
if functions -q deactivate
|
||||
setenv PYENV_DEACTIVATE "\$VIRTUAL_ENV";
|
||||
setenv PYENV_DEACTIVATE "$VIRTUAL_ENV";
|
||||
deactivate;
|
||||
else;
|
||||
false;
|
||||
@@ -107,8 +132,9 @@ end;
|
||||
EOS
|
||||
}
|
||||
|
||||
@test "deactivate virtualenv (fish) (w/o pyenv-virtualenv-init)" {
|
||||
@test "deactivate virtualenv (fish) (without pyenv-virtualenv-init)" {
|
||||
export PYENV_VIRTUALENV_INIT=
|
||||
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
|
||||
|
||||
PYENV_SHELL="fish" run pyenv-sh-deactivate
|
||||
|
||||
@@ -116,7 +142,7 @@ EOS
|
||||
assert_output <<EOS
|
||||
if functions -q deactivate
|
||||
pyenv shell --unset;
|
||||
setenv PYENV_DEACTIVATE "\$VIRTUAL_ENV";
|
||||
setenv PYENV_DEACTIVATE "$VIRTUAL_ENV";
|
||||
deactivate;
|
||||
else;
|
||||
echo "pyenv-virtualenv: no virtualenv has been activated." 1>&2;
|
||||
@@ -125,8 +151,9 @@ end;
|
||||
EOS
|
||||
}
|
||||
|
||||
@test "deactivate virtualenv (fish) (w/o pyenv-virtualenv-init) (no-error)" {
|
||||
@test "deactivate virtualenv (fish) (without pyenv-virtualenv-init) (no-error)" {
|
||||
export PYENV_VIRTUALENV_INIT=
|
||||
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
|
||||
|
||||
PYENV_SHELL="fish" run pyenv-sh-deactivate --no-error
|
||||
|
||||
@@ -134,7 +161,7 @@ EOS
|
||||
assert_output <<EOS
|
||||
if functions -q deactivate
|
||||
pyenv shell --unset;
|
||||
setenv PYENV_DEACTIVATE "\$VIRTUAL_ENV";
|
||||
setenv PYENV_DEACTIVATE "$VIRTUAL_ENV";
|
||||
deactivate;
|
||||
else;
|
||||
false;
|
||||
|
||||
@@ -33,16 +33,16 @@ export PYENV_VIRTUALENV_INIT=1;
|
||||
_pyenv_virtualenv_hook() {
|
||||
if [ -n "\$VIRTUAL_ENV" ]; then
|
||||
if [ "x\`pyenv version-name\`" = "xsystem" ]; then
|
||||
pyenv deactivate || true
|
||||
pyenv deactivate --no-error --verbose
|
||||
return 0
|
||||
fi
|
||||
if [ "x\$VIRTUAL_ENV" != "x\`pyenv prefix\`" ]; then
|
||||
pyenv deactivate || true
|
||||
pyenv activate 2>/dev/null || true
|
||||
pyenv deactivate --no-error --verbose
|
||||
pyenv activate --no-error --verbose
|
||||
fi
|
||||
else
|
||||
if [ "x\$PYENV_DEACTIVATE" != "x\`pyenv prefix\`" ]; then
|
||||
pyenv activate 2>/dev/null || true
|
||||
pyenv activate --no-error --verbose
|
||||
fi
|
||||
fi
|
||||
};
|
||||
@@ -60,16 +60,16 @@ setenv PYENV_VIRTUALENV_INIT 1;
|
||||
function _pyenv_virtualenv_hook --on-event fish_prompt;
|
||||
if [ -n "\$VIRTUAL_ENV" ]
|
||||
if [ (pyenv version-name) = "system" ]
|
||||
eval (pyenv sh-deactivate); or true
|
||||
eval (pyenv sh-deactivate --no-error --verbose)
|
||||
return 0
|
||||
end
|
||||
if [ "\$VIRTUAL_ENV" != (pyenv prefix) ]
|
||||
eval (pyenv sh-deactivate); or true
|
||||
eval (pyenv sh-activate 2>/dev/null); or true
|
||||
eval (pyenv sh-deactivate --no-error --verbose)
|
||||
eval (pyenv sh-activate --no-error --verbose)
|
||||
end
|
||||
else
|
||||
if [ "\$PYENV_DEACTIVATE" != (pyenv prefix) ]
|
||||
eval (pyenv sh-activate 2>/dev/null); or true
|
||||
eval (pyenv sh-activate --no-error --verbose)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -84,16 +84,16 @@ export PYENV_VIRTUALENV_INIT=1;
|
||||
_pyenv_virtualenv_hook() {
|
||||
if [ -n "\$VIRTUAL_ENV" ]; then
|
||||
if [ "x\`pyenv version-name\`" = "xsystem" ]; then
|
||||
pyenv deactivate || true
|
||||
pyenv deactivate --no-error --verbose
|
||||
return 0
|
||||
fi
|
||||
if [ "x\$VIRTUAL_ENV" != "x\`pyenv prefix\`" ]; then
|
||||
pyenv deactivate || true
|
||||
pyenv activate 2>/dev/null || true
|
||||
pyenv deactivate --no-error --verbose
|
||||
pyenv activate --no-error --verbose
|
||||
fi
|
||||
else
|
||||
if [ "x\$PYENV_DEACTIVATE" != "x\`pyenv prefix\`" ]; then
|
||||
pyenv activate 2>/dev/null || true
|
||||
pyenv activate --no-error --verbose
|
||||
fi
|
||||
fi
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user