@@ -55,10 +55,18 @@ GLOBAL postmkvirtualenv"
5555}
5656
5757test_no_virtualenv () {
58+ # Find "which" before we change the path
59+ which=$( which which)
5860 old_path=" $PATH "
5961 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
6270 RC=$?
6371 # Restore the path before testing because
6472 # the test script depends on commands in the
@@ -111,6 +119,25 @@ test_mkvirtualenv_args () {
111119 unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS
112120}
113121
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+
114141test_virtualenv_fails () {
115142 # Test to reproduce the conditions in issue #76
116143 # https://bitbucket.org/dhellmann/virtualenvwrapper/issue/76/
0 commit comments