Ver a proveniência

1) Made `--quiet` as opposite of `--verbose` 2) Suppress warning about prompts on `--quiet`

pull/171/head
Yamashita, Yuu há 8 anos
ascendente
cometimento
c64aebef08
5 ficheiros alterados com 65 adições e 8 eliminações
  1. +8
    -5
      bin/pyenv-sh-activate
  2. +1
    -2
      bin/pyenv-sh-deactivate
  3. +26
    -1
      test/activate.bats
  4. +30
    -0
      test/deactivate.bats
  5. +0
    -0
      test/init.bats

+ 8
- 5
bin/pyenv-sh-activate Ver ficheiro

@ -24,7 +24,6 @@ resolve_link() {
unset FORCE
unset QUIET
unset VERBOSE
while [ $# -gt 0 ]; do
case "$1" in
@ -47,7 +46,7 @@ while [ $# -gt 0 ]; do
exec pyenv-sh-deactivate
;;
"-v" | "--verbose" )
VERBOSE=1
unset QUIET
;;
* )
break
@ -136,7 +135,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 +219,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}";

+ 1
- 2
bin/pyenv-sh-deactivate Ver ficheiro

@ -15,7 +15,6 @@ fi
unset FORCE
unset QUIET
unset VERBOSE
while [ $# -gt 0 ]; do
case "$1" in
@ -30,7 +29,7 @@ while [ $# -gt 0 ]; do
QUIET=1
;;
"-v" | "--verbose" )
VERBOSE=1
unset QUIET
;;
* )
break

+ 26
- 1
test/activate.bats Ver ficheiro

@ -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

+ 30
- 0
test/deactivate.bats Ver ficheiro

@ -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
- 0
test/init.bats Ver ficheiro


Carregando…
Cancelar
Guardar