Skip to content

Commit 141de5e

Browse files
committed
fix tests for changes to virtualenvwrapper_verify_workon_home
1 parent 8cc9759 commit 141de5e

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

tests/test.sh

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ test_virtualenvwrapper_verify_workon_home() {
5656
test_virtualenvwrapper_verify_workon_home_missing_dir() {
5757
old_home="$WORKON_HOME"
5858
WORKON_HOME="$WORKON_HOME/not_there"
59-
assertFalse "WORKON_HOME verified unexpectedly" virtualenvwrapper_verify_workon_home
59+
output=$(virtualenvwrapper_verify_workon_home 2>&1)
60+
assertSame "NOTE: Virtual environments directory $WORKON_HOME does not exist. Creating..." "$output"
61+
assertTrue "WORKON_HOME verified unexpectedly" virtualenvwrapper_verify_workon_home
6062
WORKON_HOME="$old_home"
6163
}
6264

@@ -66,19 +68,11 @@ test_virtualenvwrapper_verify_workon_home_missing_dir_grep_options() {
6668
# This should prevent the message from being found if it isn't
6769
# unset correctly.
6870
export GREP_OPTIONS="--count"
69-
assertFalse "WORKON_HOME verified unexpectedly" virtualenvwrapper_verify_workon_home
71+
assertTrue "WORKON_HOME not verified" virtualenvwrapper_verify_workon_home
7072
WORKON_HOME="$old_home"
7173
unset GREP_OPTIONS
7274
}
7375

74-
test_virtualenvwrapper_verify_workon_home_missing_dir_quiet_init() {
75-
old_home="$WORKON_HOME"
76-
export WORKON_HOME="$WORKON_HOME/not_there"
77-
output=$(source $test_dir/../virtualenvwrapper.sh 2>&1)
78-
assertSame "" "$output"
79-
WORKON_HOME="$old_home"
80-
}
81-
8276
test_get_python_version() {
8377
expected=$(python -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d.)
8478
actual=$(virtualenvwrapper_get_python_version)

tests/test_cd.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ setUp () {
2626
}
2727

2828
tearDown () {
29-
deactivate
29+
deactivate >/dev/null 2>&1
3030
}
3131

3232
test_cdvirtual() {
@@ -60,16 +60,18 @@ test_cdsitepackages_with_arg () {
6060
test_cdvirtualenv_no_workon_home () {
6161
old_home="$WORKON_HOME"
6262
export WORKON_HOME="$WORKON_HOME/not_there"
63-
output=`cdvirtualenv 2>&1`
63+
output=$(cdvirtualenv 2>&1)
6464
assertTrue "Did not see expected message" "echo $output | grep 'does not exist'"
6565
WORKON_HOME="$old_home"
6666
}
6767

6868
test_cdsitepackages_no_workon_home () {
69+
deactivate 2>&1
6970
old_home="$WORKON_HOME"
71+
cd "$WORKON_HOME"
7072
export WORKON_HOME="$WORKON_HOME/not_there"
71-
output=`cdsitepackages 2>&1`
72-
assertTrue "Did not see expected message" "echo $output | grep 'does not exist'"
73+
assertFalse "Was able to change to site-packages" cdsitepackages
74+
assertSame "$old_home" "$(pwd)"
7375
WORKON_HOME="$old_home"
7476
}
7577

tests/test_cp.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test_dir=$(cd $(dirname $0) && pwd)
66

77
export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')"
88

9-
unset HOOK_VERBOSE_OPTION
9+
#unset HOOK_VERBOSE_OPTION
1010

1111
setUp () {
1212
rm -rf "$WORKON_HOME"

virtualenvwrapper.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ virtualenvwrapper_derive_workon_home() {
9797
virtualenvwrapper_verify_workon_home () {
9898
if [ ! -d "$WORKON_HOME" ]
9999
then
100-
[ "$1" != "-q" ] && echo "NOTE: Virtual environments directory '$WORKON_HOME' does not exist. Creating..." 1>&2
100+
[ "$1" != "-q" ] && echo "NOTE: Virtual environments directory $WORKON_HOME does not exist. Creating..." 1>&2
101101
mkdir $WORKON_HOME
102102
fi
103103
return 0
104104
}
105105

106-
#HOOK_VERBOSE_OPTION="-v"
106+
#HOOK_VERBOSE_OPTION="-q"
107107

108108
# Expects 1 argument, the suffix for the new file.
109109
virtualenvwrapper_tempfile () {

0 commit comments

Comments
 (0)