@@ -55,10 +55,18 @@ GLOBAL postmkvirtualenv"
55
55
}
56
56
57
57
test_no_virtualenv () {
58
+ # Find "which" before we change the path
59
+ which=$( which which)
58
60
old_path=" $PATH "
59
61
PATH=" /bin:/usr/sbin:/sbin"
60
- assertFalse " Found virtualenv in $( which virtualenv) " " which virtualenv"
61
- mkvirtualenv should_not_be_created 2> /dev/null
62
+ venv=$( $which virtualenv 2> /dev/null)
63
+ if [ ! -z " $venv " ]
64
+ then
65
+ echo " FOUND \" $venv \" in PATH so skipping this test"
66
+ export PATH=" $old_path "
67
+ return 0
68
+ fi
69
+ mkvirtualenv should_not_be_created > /dev/null 2>&1
62
70
RC=$?
63
71
# Restore the path before testing because
64
72
# the test script depends on commands in the
@@ -111,6 +119,25 @@ test_mkvirtualenv_args () {
111
119
unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS
112
120
}
113
121
122
+ test_no_such_virtualenv () {
123
+ VIRTUALENVWRAPPER_VIRTUALENV=/path/to/missing/program
124
+
125
+ echo " #!/bin/sh" > " $WORKON_HOME /premkvirtualenv"
126
+ echo " echo GLOBAL premkvirtualenv \` pwd\` \"\$ @\" >> \" $pre_test_dir /catch_output\" " >> " $WORKON_HOME /premkvirtualenv"
127
+ chmod +x " $WORKON_HOME /premkvirtualenv"
128
+
129
+ echo " echo GLOBAL postmkvirtualenv >> $test_dir /catch_output" > " $WORKON_HOME /postmkvirtualenv"
130
+ mkvirtualenv " env3" > /dev/null 2>&1
131
+ output=$( cat " $test_dir /catch_output" 2> /dev/null)
132
+ workon_home_as_pwd=$( cd $WORKON_HOME ; pwd)
133
+ expected=" "
134
+ assertSame " $expected " " $output "
135
+ rm -f " $WORKON_HOME /premkvirtualenv"
136
+ rm -f " $WORKON_HOME /postmkvirtualenv"
137
+
138
+ VIRTUALENVWRAPPER_VIRTUALENV=virtualenv
139
+ }
140
+
114
141
test_virtualenv_fails () {
115
142
# Test to reproduce the conditions in issue #76
116
143
# https://bitbucket.org/dhellmann/virtualenvwrapper/issue/76/
0 commit comments