mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-08 11:33:55 -05:00
Merge pull request #171 from yyuu/simplified-messaging-levels
Simplified messaging levels
This commit is contained in:
@@ -24,7 +24,6 @@ resolve_link() {
|
||||
|
||||
unset FORCE
|
||||
unset QUIET
|
||||
unset VERBOSE
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
@@ -36,10 +35,6 @@ while [ $# -gt 0 ]; do
|
||||
"-f" | "--force" )
|
||||
FORCE=1
|
||||
;;
|
||||
"--no-error" )
|
||||
# for backward compatibility with v20151103 and earlier
|
||||
QUIET=1
|
||||
;;
|
||||
"-q" | "--quiet" )
|
||||
QUIET=1
|
||||
;;
|
||||
@@ -47,7 +42,8 @@ while [ $# -gt 0 ]; do
|
||||
exec pyenv-sh-deactivate
|
||||
;;
|
||||
"-v" | "--verbose" )
|
||||
VERBOSE=1
|
||||
unset QUIET
|
||||
PYENV_VIRTUALENV_VERBOSE_ACTIVATE=1
|
||||
;;
|
||||
* )
|
||||
break
|
||||
@@ -136,7 +132,7 @@ if [[ "${VIRTUAL_ENV}" == "${prefix}" ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
pyenv-sh-deactivate --force --quiet ${VERBOSE+--verbose} || true
|
||||
pyenv-sh-deactivate --force --quiet || true
|
||||
|
||||
if [ -n "$PYENV_VIRTUALENV_VERBOSE_ACTIVATE" ]; then
|
||||
echo "pyenv-virtualenv: activate ${venv}" 1>&2
|
||||
@@ -220,10 +216,14 @@ PYENV_VIRTUALENV_DISABLE_PROMPT="${PYENV_VIRTUALENV_DISABLE_PROMPT:-${VIRTUAL_EN
|
||||
if [ -z "${PYENV_VIRTUALENV_DISABLE_PROMPT}" ]; then
|
||||
case "${shell}" in
|
||||
fish )
|
||||
echo "pyenv-virtualenv: prompt changing not working for fish." 1>&2
|
||||
if [ -z "${QUIET}" ]; then
|
||||
echo "pyenv-virtualenv: prompt changing not working for fish." 1>&2
|
||||
fi
|
||||
;;
|
||||
* )
|
||||
echo "pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior." 1>&2
|
||||
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
|
||||
fi
|
||||
cat <<EOS
|
||||
export _OLD_VIRTUAL_PS1="\${PS1}";
|
||||
export PS1="(${venv}) \${PS1}";
|
||||
|
||||
@@ -15,22 +15,18 @@ fi
|
||||
|
||||
unset FORCE
|
||||
unset QUIET
|
||||
unset VERBOSE
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
"-f" | "--force" )
|
||||
FORCE=1
|
||||
;;
|
||||
"--no-error" )
|
||||
# for backward compatibility with v20151103 and earlier
|
||||
QUIET=1
|
||||
;;
|
||||
"-q" | "--quiet")
|
||||
QUIET=1
|
||||
;;
|
||||
"-v" | "--verbose" )
|
||||
VERBOSE=1
|
||||
unset QUIET
|
||||
PYENV_VIRTUALENV_VERBOSE_ACTIVATE=1
|
||||
;;
|
||||
* )
|
||||
break
|
||||
|
||||
@@ -44,6 +44,31 @@ EOS
|
||||
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)" {
|
||||
export PYENV_VIRTUALENV_INIT=1
|
||||
export PYENV_VIRTUALENV_VERBOSE_ACTIVATE=1
|
||||
@@ -51,7 +76,7 @@ EOS
|
||||
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 --verbose : echo deactivated"
|
||||
stub pyenv-sh-deactivate "--force --quiet : echo deactivated"
|
||||
|
||||
PYENV_SHELL="bash" PYENV_VERSION="venv" run pyenv-sh-activate --verbose
|
||||
|
||||
|
||||
@@ -48,6 +48,36 @@ fi;
|
||||
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)" {
|
||||
export PYENV_VIRTUALENV_INIT=1
|
||||
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