Commits

Doug Hellmann committed 141de5e

fix tests for changes to virtualenvwrapper_verify_workon_home

Comments (0)

Files changed (4)

 test_virtualenvwrapper_verify_workon_home_missing_dir() {
     old_home="$WORKON_HOME"
     WORKON_HOME="$WORKON_HOME/not_there"
-    assertFalse "WORKON_HOME verified unexpectedly" virtualenvwrapper_verify_workon_home
+    output=$(virtualenvwrapper_verify_workon_home 2>&1)
+    assertSame "NOTE: Virtual environments directory $WORKON_HOME does not exist. Creating..." "$output"
+    assertTrue "WORKON_HOME verified unexpectedly" virtualenvwrapper_verify_workon_home
     WORKON_HOME="$old_home"
 }
 
     # This should prevent the message from being found if it isn't
     # unset correctly.
     export GREP_OPTIONS="--count"
-    assertFalse "WORKON_HOME verified unexpectedly" virtualenvwrapper_verify_workon_home
+    assertTrue "WORKON_HOME not verified" virtualenvwrapper_verify_workon_home
     WORKON_HOME="$old_home"
     unset GREP_OPTIONS
 }
 
-test_virtualenvwrapper_verify_workon_home_missing_dir_quiet_init() {
-    old_home="$WORKON_HOME"
-    export WORKON_HOME="$WORKON_HOME/not_there"
-    output=$(source $test_dir/../virtualenvwrapper.sh 2>&1)
-    assertSame "" "$output"
-    WORKON_HOME="$old_home"
-}
-
 test_get_python_version() {
     expected=$(python -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d.)
     actual=$(virtualenvwrapper_get_python_version)
 }
 
 tearDown () {
-    deactivate
+    deactivate >/dev/null 2>&1
 }
 
 test_cdvirtual() {
 test_cdvirtualenv_no_workon_home () {
     old_home="$WORKON_HOME"
     export WORKON_HOME="$WORKON_HOME/not_there"
-    output=`cdvirtualenv 2>&1`
+    output=$(cdvirtualenv 2>&1)
     assertTrue "Did not see expected message" "echo $output | grep 'does not exist'"
     WORKON_HOME="$old_home"
 }
 
 test_cdsitepackages_no_workon_home () {
+    deactivate 2>&1
     old_home="$WORKON_HOME"
+    cd "$WORKON_HOME"
     export WORKON_HOME="$WORKON_HOME/not_there"
-    output=`cdsitepackages 2>&1`
-    assertTrue "Did not see expected message" "echo $output | grep 'does not exist'"
+    assertFalse "Was able to change to site-packages" cdsitepackages
+    assertSame "$old_home" "$(pwd)"
     WORKON_HOME="$old_home"
 }
 
 
 export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')"
 
-unset HOOK_VERBOSE_OPTION
+#unset HOOK_VERBOSE_OPTION
 
 setUp () {
     rm -rf "$WORKON_HOME"

virtualenvwrapper.sh

 virtualenvwrapper_verify_workon_home () {
     if [ ! -d "$WORKON_HOME" ]
     then
-        [ "$1" != "-q" ] && echo "NOTE: Virtual environments directory '$WORKON_HOME' does not exist.  Creating..." 1>&2
+        [ "$1" != "-q" ] && echo "NOTE: Virtual environments directory $WORKON_HOME does not exist. Creating..." 1>&2
         mkdir $WORKON_HOME
     fi
     return 0
 }
 
-#HOOK_VERBOSE_OPTION="-v"
+#HOOK_VERBOSE_OPTION="-q"
 
 # Expects 1 argument, the suffix for the new file.
 virtualenvwrapper_tempfile () {