File tree 2 files changed +26
-2
lines changed
2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 336
336
# Set VERSION_NAME as default version in this script
337
337
export PYENV_VERSION=" ${VERSION_NAME} "
338
338
339
+ not_installed_message () {
340
+ local is_available=$( python-build --definitions | grep -F -x " $1 " )
341
+ echo " pyenv-virtualenv: \` ${1} ' is not installed in pyenv." 1>&2
342
+ if [[ $is_available ]]; then
343
+ echo " Run \` pyenv install ${1} ' to install it." 1>&2
344
+ else
345
+ echo " It does not look like a valid Python version. See \` pyenv install --list' for available versions." 1>&2
346
+ fi
347
+ }
348
+
339
349
# Source version must exist before creating virtualenv.
340
350
PREFIX=" $( pyenv-prefix 2> /dev/null || true) "
341
351
if [ ! -d " ${PREFIX} " ]; then
342
- echo " pyenv-virtualenv: \` ${PYENV_VERSION} ' is not installed in pyenv. " 1>&2
352
+ not_installed_message " ${PYENV_VERSION} "
343
353
exit 1
344
354
fi
345
355
441
451
if [ -x " ${python} " ]; then
442
452
VIRTUALENV_OPTIONS[${# VIRTUALENV_OPTIONS[*]} ]=" --python=${python} "
443
453
else
444
- echo " pyenv-virtualenv: \` ${VIRTUALENV_PYTHON##*/ } ' is not installed in pyenv." 1>&2
454
+ # echo "pyenv-virtualenv: \`${VIRTUALENV_PYTHON##*/}' is not installed in pyenv." 1>&2
455
+ not_installed_message " ${VIRTUALENV_PYTHON##*/ } "
445
456
exit 1
446
457
fi
447
458
fi
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ setup() {
14
14
stub pyenv-rehash " : true"
15
15
stub pyenv-version-name " echo \$ {PYENV_VERSION}"
16
16
stub curl true
17
+ stub python-build " echo python2.7"
17
18
}
18
19
19
20
teardown () {
@@ -22,6 +23,7 @@ teardown() {
22
23
unstub pyenv-prefix
23
24
unstub pyenv-hooks
24
25
unstub pyenv-rehash
26
+ unstub python-build
25
27
teardown_version " 2.7.8"
26
28
rm -fr " $TMP " /*
27
29
}
96
98
97
99
assert_output << OUT
98
100
pyenv-virtualenv: \` python2.7' is not installed in pyenv.
101
+ Run \` pyenv install python2.7' to install it.
99
102
OUT
100
103
assert_failure
101
104
106
109
remove_executable " 2.7.8" " python2.7"
107
110
remove_executable " 2.7.9" " python2.7"
108
111
}
112
+
113
+ @test " invalid python name" {
114
+ run pyenv-virtualenv --verbose --python=99.99.99 venv
115
+
116
+ assert_output << OUT
117
+ pyenv-virtualenv: \` 99.99.99' is not installed in pyenv.
118
+ It does not look like a valid Python version. See \` pyenv install --list' for available versions.
119
+ OUT
120
+ assert_failure
121
+ }
You can’t perform that action at this time.
0 commit comments