mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-08 03:23:54 -05:00
Don't activate if a 3rd-party virtualenv is active over ours
This commit is contained in:
@@ -96,8 +96,8 @@ fi
|
||||
venv="${versions}"
|
||||
|
||||
if [ -n "${VIRTUAL_ENV}" ]; then
|
||||
# exit as success if some virtualenv is already activated outside from pyenv-virtualenv
|
||||
if [ -z "${PYENV_VIRTUAL_ENV}" ]; then
|
||||
# exit as success if a non-pyenv virtualenv is active
|
||||
if [[ -z $PYENV_VIRTUAL_ENV || $PYENV_VIRTUAL_ENV != "$VIRTUAL_ENV" ]]; then
|
||||
if [ -z "${FORCE}" ]; then
|
||||
if [ -z "${QUIET}" ]; then
|
||||
echo "pyenv-virtualenv: virtualenv \`${VIRTUAL_ENV}' is already activated" 1>&2
|
||||
|
||||
@@ -439,6 +439,34 @@ EOS
|
||||
unstub pyenv-prefix
|
||||
}
|
||||
|
||||
@test "do nothing if a 3rd-party virtualenv is active" {
|
||||
export PYENV_VIRTUALENV_INIT=1
|
||||
export VIRTUAL_ENV="${TMP}/venv-3rd-party"
|
||||
unset PYENV_VIRTUAL_ENV
|
||||
|
||||
PYENV_SHELL="bash" run pyenv-sh-activate "venv"
|
||||
|
||||
assert_success
|
||||
assert_output <<EOS
|
||||
pyenv-virtualenv: virtualenv \`${TMP}/venv-3rd-party' is already activated
|
||||
true
|
||||
EOS
|
||||
}
|
||||
|
||||
@test "do nothing if a 3rd-party virtualenv is active over ours" {
|
||||
export PYENV_VIRTUALENV_INIT=1
|
||||
export VIRTUAL_ENV="${TMP}/venv-3rd-party"
|
||||
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
|
||||
|
||||
PYENV_SHELL="bash" run pyenv-sh-activate "venv"
|
||||
|
||||
assert_success
|
||||
assert_output <<EOS
|
||||
pyenv-virtualenv: virtualenv \`${TMP}/venv-3rd-party' is already activated
|
||||
true
|
||||
EOS
|
||||
}
|
||||
|
||||
@test "should fail if activate is invoked as a command" {
|
||||
run pyenv-activate
|
||||
|
||||
|
||||
Reference in New Issue
Block a user