mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-09 12:03:55 -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}"
|
venv="${versions}"
|
||||||
|
|
||||||
if [ -n "${VIRTUAL_ENV}" ]; then
|
if [ -n "${VIRTUAL_ENV}" ]; then
|
||||||
# exit as success if some virtualenv is already activated outside from pyenv-virtualenv
|
# exit as success if a non-pyenv virtualenv is active
|
||||||
if [ -z "${PYENV_VIRTUAL_ENV}" ]; then
|
if [[ -z $PYENV_VIRTUAL_ENV || $PYENV_VIRTUAL_ENV != "$VIRTUAL_ENV" ]]; then
|
||||||
if [ -z "${FORCE}" ]; then
|
if [ -z "${FORCE}" ]; then
|
||||||
if [ -z "${QUIET}" ]; then
|
if [ -z "${QUIET}" ]; then
|
||||||
echo "pyenv-virtualenv: virtualenv \`${VIRTUAL_ENV}' is already activated" 1>&2
|
echo "pyenv-virtualenv: virtualenv \`${VIRTUAL_ENV}' is already activated" 1>&2
|
||||||
|
|||||||
@@ -439,6 +439,34 @@ EOS
|
|||||||
unstub pyenv-prefix
|
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" {
|
@test "should fail if activate is invoked as a command" {
|
||||||
run pyenv-activate
|
run pyenv-activate
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user