mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-10 04:23:53 -05:00
1) Made --quiet as opposite of --verbose 2) Suppress warning about prompts on --quiet
This commit is contained in:
@@ -24,7 +24,6 @@ resolve_link() {
|
|||||||
|
|
||||||
unset FORCE
|
unset FORCE
|
||||||
unset QUIET
|
unset QUIET
|
||||||
unset VERBOSE
|
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@@ -47,7 +46,7 @@ while [ $# -gt 0 ]; do
|
|||||||
exec pyenv-sh-deactivate
|
exec pyenv-sh-deactivate
|
||||||
;;
|
;;
|
||||||
"-v" | "--verbose" )
|
"-v" | "--verbose" )
|
||||||
VERBOSE=1
|
unset QUIET
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
break
|
break
|
||||||
@@ -136,7 +135,7 @@ if [[ "${VIRTUAL_ENV}" == "${prefix}" ]]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pyenv-sh-deactivate --force --quiet ${VERBOSE+--verbose} || true
|
pyenv-sh-deactivate --force --quiet || true
|
||||||
|
|
||||||
if [ -n "$PYENV_VIRTUALENV_VERBOSE_ACTIVATE" ]; then
|
if [ -n "$PYENV_VIRTUALENV_VERBOSE_ACTIVATE" ]; then
|
||||||
echo "pyenv-virtualenv: activate ${venv}" 1>&2
|
echo "pyenv-virtualenv: activate ${venv}" 1>&2
|
||||||
@@ -220,10 +219,14 @@ PYENV_VIRTUALENV_DISABLE_PROMPT="${PYENV_VIRTUALENV_DISABLE_PROMPT:-${VIRTUAL_EN
|
|||||||
if [ -z "${PYENV_VIRTUALENV_DISABLE_PROMPT}" ]; then
|
if [ -z "${PYENV_VIRTUALENV_DISABLE_PROMPT}" ]; then
|
||||||
case "${shell}" in
|
case "${shell}" in
|
||||||
fish )
|
fish )
|
||||||
|
if [ -z "${QUIET}" ]; then
|
||||||
echo "pyenv-virtualenv: prompt changing not working for fish." 1>&2
|
echo "pyenv-virtualenv: prompt changing not working for fish." 1>&2
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
|
if [ -z "${QUIET}" ]; then
|
||||||
echo "pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior." 1>&2
|
echo "pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior." 1>&2
|
||||||
|
fi
|
||||||
cat <<EOS
|
cat <<EOS
|
||||||
export _OLD_VIRTUAL_PS1="\${PS1}";
|
export _OLD_VIRTUAL_PS1="\${PS1}";
|
||||||
export PS1="(${venv}) \${PS1}";
|
export PS1="(${venv}) \${PS1}";
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ fi
|
|||||||
|
|
||||||
unset FORCE
|
unset FORCE
|
||||||
unset QUIET
|
unset QUIET
|
||||||
unset VERBOSE
|
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@@ -30,7 +29,7 @@ while [ $# -gt 0 ]; do
|
|||||||
QUIET=1
|
QUIET=1
|
||||||
;;
|
;;
|
||||||
"-v" | "--verbose" )
|
"-v" | "--verbose" )
|
||||||
VERBOSE=1
|
unset QUIET
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -44,6 +44,31 @@ EOS
|
|||||||
unstub pyenv-sh-deactivate
|
unstub pyenv-sh-deactivate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "activate virtualenv from current version (quiet)" {
|
||||||
|
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\""
|
||||||
|
stub pyenv-sh-deactivate "--force --quiet : echo deactivated"
|
||||||
|
|
||||||
|
PYENV_SHELL="bash" PYENV_VERSION="venv" run pyenv-sh-activate --quiet
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
assert_output <<EOS
|
||||||
|
deactivated
|
||||||
|
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv";
|
||||||
|
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv";
|
||||||
|
export _OLD_VIRTUAL_PS1="\${PS1}";
|
||||||
|
export PS1="(venv) \${PS1}";
|
||||||
|
EOS
|
||||||
|
|
||||||
|
unstub pyenv-version-name
|
||||||
|
unstub pyenv-virtualenv-prefix
|
||||||
|
unstub pyenv-prefix
|
||||||
|
unstub pyenv-sh-deactivate
|
||||||
|
}
|
||||||
|
|
||||||
@test "activate virtualenv from current version (verbose)" {
|
@test "activate virtualenv from current version (verbose)" {
|
||||||
export PYENV_VIRTUALENV_INIT=1
|
export PYENV_VIRTUALENV_INIT=1
|
||||||
export PYENV_VIRTUALENV_VERBOSE_ACTIVATE=1
|
export PYENV_VIRTUALENV_VERBOSE_ACTIVATE=1
|
||||||
@@ -51,7 +76,7 @@ EOS
|
|||||||
stub pyenv-version-name "echo venv"
|
stub pyenv-version-name "echo venv"
|
||||||
stub pyenv-virtualenv-prefix "venv : echo \"${PYENV_ROOT}/versions/venv\""
|
stub pyenv-virtualenv-prefix "venv : echo \"${PYENV_ROOT}/versions/venv\""
|
||||||
stub pyenv-prefix "venv : echo \"${PYENV_ROOT}/versions/venv\""
|
stub pyenv-prefix "venv : echo \"${PYENV_ROOT}/versions/venv\""
|
||||||
stub pyenv-sh-deactivate "--force --quiet --verbose : echo deactivated"
|
stub pyenv-sh-deactivate "--force --quiet : echo deactivated"
|
||||||
|
|
||||||
PYENV_SHELL="bash" PYENV_VERSION="venv" run pyenv-sh-activate --verbose
|
PYENV_SHELL="bash" PYENV_VERSION="venv" run pyenv-sh-activate --verbose
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,36 @@ fi;
|
|||||||
EOS
|
EOS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "deactivate virtualenv (quiet)" {
|
||||||
|
export PYENV_VIRTUALENV_INIT=1
|
||||||
|
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
|
||||||
|
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
|
||||||
|
export PYENV_ACTIVATE_SHELL=
|
||||||
|
|
||||||
|
PYENV_SHELL="bash" run pyenv-sh-deactivate --quit
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
assert_output <<EOS
|
||||||
|
unset PYENV_VIRTUAL_ENV;
|
||||||
|
unset VIRTUAL_ENV;
|
||||||
|
if [ -n "\${_OLD_VIRTUAL_PATH}" ]; then
|
||||||
|
export PATH="\${_OLD_VIRTUAL_PATH}";
|
||||||
|
unset _OLD_VIRTUAL_PATH;
|
||||||
|
fi;
|
||||||
|
if [ -n "\${_OLD_VIRTUAL_PYTHONHOME}" ]; then
|
||||||
|
export PYTHONHOME="\${_OLD_VIRTUAL_PYTHONHOME}";
|
||||||
|
unset _OLD_VIRTUAL_PYTHONHOME;
|
||||||
|
fi;
|
||||||
|
if [ -n "\${_OLD_VIRTUAL_PS1}" ]; then
|
||||||
|
export PS1="\${_OLD_VIRTUAL_PS1}";
|
||||||
|
unset _OLD_VIRTUAL_PS1;
|
||||||
|
fi;
|
||||||
|
if declare -f deactivate 1>/dev/null 2>&1; then
|
||||||
|
unset -f deactivate;
|
||||||
|
fi;
|
||||||
|
EOS
|
||||||
|
}
|
||||||
|
|
||||||
@test "deactivate virtualenv (verbose)" {
|
@test "deactivate virtualenv (verbose)" {
|
||||||
export PYENV_VIRTUALENV_INIT=1
|
export PYENV_VIRTUALENV_INIT=1
|
||||||
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
|
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
|
||||||
|
|||||||
0
test/init.bats
Executable file → Normal file
0
test/init.bats
Executable file → Normal file
Reference in New Issue
Block a user