mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-14 06:23:52 -05:00
Merge pull request #63 from wwwjfy/master
fix warns for virtualenv-init corner case on fish
This commit is contained in:
@@ -76,12 +76,12 @@ fish )
|
|||||||
cat <<EOS
|
cat <<EOS
|
||||||
function _pyenv_virtualenv_hook --on-event fish_prompt;
|
function _pyenv_virtualenv_hook --on-event fish_prompt;
|
||||||
if [ -n "\$PYENV_ACTIVATE" ]
|
if [ -n "\$PYENV_ACTIVATE" ]
|
||||||
if [ (pyenv version-name 2>/dev/null; or true) = "system" ]
|
if [ "(pyenv version-name 2>/dev/null; or true)" = "system" ]
|
||||||
pyenv deactivate --no-error --verbose
|
pyenv deactivate --no-error --verbose
|
||||||
set -e PYENV_DEACTIVATE
|
set -e PYENV_DEACTIVATE
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
if [ "\$PYENV_ACTIVATE" != (pyenv prefix 2>/dev/null; or true) ]
|
if [ "\$PYENV_ACTIVATE" != "(pyenv prefix 2>/dev/null; or true)" ]
|
||||||
if pyenv deactivate --no-error --verbose
|
if pyenv deactivate --no-error --verbose
|
||||||
set -e PYENV_DEACTIVATE
|
set -e PYENV_DEACTIVATE
|
||||||
pyenv activate --no-error --verbose; or set -e PYENV_DEACTIVATE
|
pyenv activate --no-error --verbose; or set -e PYENV_DEACTIVATE
|
||||||
@@ -90,7 +90,7 @@ function _pyenv_virtualenv_hook --on-event fish_prompt;
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if [ -z "\$VIRTUAL_ENV" ]; and [ "\$PYENV_DEACTIVATE" != (pyenv prefix 2>/dev/null; or true) ]
|
if [ -z "\$VIRTUAL_ENV" ]; and [ "\$PYENV_DEACTIVATE" != "(pyenv prefix 2>/dev/null; or true)" ]
|
||||||
pyenv activate --no-error --verbose
|
pyenv activate --no-error --verbose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ EOS
|
|||||||
stub pyenv-virtualenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
stub pyenv-virtualenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
||||||
stub pyenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
stub pyenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
||||||
|
|
||||||
run pyenv-sh-activate "venv27"
|
PYENV_SHELL="bash" PYENV_VERSION="venv" run pyenv-sh-activate "venv27"
|
||||||
|
|
||||||
unstub pyenv-virtualenv-prefix
|
unstub pyenv-virtualenv-prefix
|
||||||
unstub pyenv-prefix
|
unstub pyenv-prefix
|
||||||
@@ -144,7 +144,7 @@ EOS
|
|||||||
stub pyenv-virtualenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
stub pyenv-virtualenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
||||||
stub pyenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
stub pyenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
||||||
|
|
||||||
run pyenv-sh-activate "venv27"
|
PYENV_SHELL="bash" PYENV_VERSION="venv" run pyenv-sh-activate "venv27"
|
||||||
|
|
||||||
unstub pyenv-virtualenv-prefix
|
unstub pyenv-virtualenv-prefix
|
||||||
unstub pyenv-prefix
|
unstub pyenv-prefix
|
||||||
@@ -159,6 +159,48 @@ export PYENV_ACTIVATE="${PYENV_ROOT}/versions/venv27";
|
|||||||
EOS
|
EOS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "activate virtualenv from command-line argument (fish)" {
|
||||||
|
export PYENV_VIRTUALENV_INIT=1
|
||||||
|
|
||||||
|
stub pyenv-virtualenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
||||||
|
stub pyenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
||||||
|
|
||||||
|
PYENV_SHELL="fish" PYENV_VERSION="venv" run pyenv-sh-activate "venv27"
|
||||||
|
|
||||||
|
unstub pyenv-virtualenv-prefix
|
||||||
|
unstub pyenv-prefix
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
assert_output <<EOS
|
||||||
|
pyenv shell "venv27";
|
||||||
|
setenv PYENV_ACTIVATE_SHELL 1;
|
||||||
|
set -e PYENV_DEACTIVATE;
|
||||||
|
setenv PYENV_ACTIVATE "${PYENV_ROOT}/versions/venv27";
|
||||||
|
. "${PYENV_ROOT}/versions/venv27/bin/activate.fish";
|
||||||
|
EOS
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "activate virtualenv from command-line argument (fish) (without pyenv-virtualenv-init)" {
|
||||||
|
export PYENV_VIRTUALENV_INIT=
|
||||||
|
|
||||||
|
stub pyenv-virtualenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
||||||
|
stub pyenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
||||||
|
|
||||||
|
PYENV_SHELL="fish" PYENV_VERSION="venv" run pyenv-sh-activate "venv27"
|
||||||
|
|
||||||
|
unstub pyenv-virtualenv-prefix
|
||||||
|
unstub pyenv-prefix
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
assert_output <<EOS
|
||||||
|
pyenv shell "venv27";
|
||||||
|
setenv PYENV_ACTIVATE_SHELL 1;
|
||||||
|
set -e PYENV_DEACTIVATE;
|
||||||
|
setenv PYENV_ACTIVATE "${PYENV_ROOT}/versions/venv27";
|
||||||
|
. "${PYENV_ROOT}/versions/venv27/bin/activate.fish";
|
||||||
|
EOS
|
||||||
|
}
|
||||||
|
|
||||||
@test "unset invokes deactivate" {
|
@test "unset invokes deactivate" {
|
||||||
run pyenv-sh-activate --unset
|
run pyenv-sh-activate --unset
|
||||||
|
|
||||||
|
|||||||
@@ -64,12 +64,12 @@ EOS
|
|||||||
setenv PYENV_VIRTUALENV_INIT 1;
|
setenv PYENV_VIRTUALENV_INIT 1;
|
||||||
function _pyenv_virtualenv_hook --on-event fish_prompt;
|
function _pyenv_virtualenv_hook --on-event fish_prompt;
|
||||||
if [ -n "\$PYENV_ACTIVATE" ]
|
if [ -n "\$PYENV_ACTIVATE" ]
|
||||||
if [ (pyenv version-name 2>/dev/null; or true) = "system" ]
|
if [ "(pyenv version-name 2>/dev/null; or true)" = "system" ]
|
||||||
pyenv deactivate --no-error --verbose
|
pyenv deactivate --no-error --verbose
|
||||||
set -e PYENV_DEACTIVATE
|
set -e PYENV_DEACTIVATE
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
if [ "\$PYENV_ACTIVATE" != (pyenv prefix 2>/dev/null; or true) ]
|
if [ "\$PYENV_ACTIVATE" != "(pyenv prefix 2>/dev/null; or true)" ]
|
||||||
if pyenv deactivate --no-error --verbose
|
if pyenv deactivate --no-error --verbose
|
||||||
set -e PYENV_DEACTIVATE
|
set -e PYENV_DEACTIVATE
|
||||||
pyenv activate --no-error --verbose; or set -e PYENV_DEACTIVATE
|
pyenv activate --no-error --verbose; or set -e PYENV_DEACTIVATE
|
||||||
@@ -78,7 +78,7 @@ function _pyenv_virtualenv_hook --on-event fish_prompt;
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if [ -z "\$VIRTUAL_ENV" ]; and [ "\$PYENV_DEACTIVATE" != (pyenv prefix 2>/dev/null; or true) ]
|
if [ -z "\$VIRTUAL_ENV" ]; and [ "\$PYENV_DEACTIVATE" != "(pyenv prefix 2>/dev/null; or true)" ]
|
||||||
pyenv activate --no-error --verbose
|
pyenv activate --no-error --verbose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user