1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#!/bin/sh
#set -x
test_dir=$(cd $(dirname $0) && pwd)
tmplocation=${TMPDIR:-/tmp}
export WORKON_HOME="$(echo ${tmplocation}/WORKON_HOME | sed 's|//|/|g')"
export HOOK_VERBOSE_OPTION=-v
oneTimeSetUp() {
rm -rf "$WORKON_HOME"
mkdir -p "$WORKON_HOME"
source "$test_dir/../virtualenvwrapper.sh"
echo $PYTHONPATH
}
oneTimeTearDown() {
rm -rf "$WORKON_HOME"
}
setUp () {
echo
rm -f "$test_dir/catch_output"
}
test_tempfile () {
filename=$(virtualenvwrapper_tempfile hook)
assertTrue "Filename is empty" "[ ! -z \"$filename\" ]"
rm -f $filename
comparable_tmpdir=$(echo $tmplocation | sed 's|/$||')
comparable_dirname=$(dirname $filename | sed 's|/$||')
assertSame "Temporary directory \"$tmplocation\" and path not the same for $filename" "$comparable_tmpdir" "$comparable_dirname"
assertTrue "virtualenvwrapper-hook not in filename." "echo $filename | grep virtualenvwrapper-hook"
}
test_no_such_tmpdir () {
old_tmpdir="$TMPDIR"
export TMPDIR="$tmplocation/does-not-exist"
virtualenvwrapper_run_hook "initialize" >/dev/null 2>&1
RC=$?
assertSame "Unexpected exit code $RC" "1" "$RC"
TMPDIR="$old_tmpdir"
}
test_tmpdir_not_writable () {
old_tmpdir="$TMPDIR"
export TMPDIR="$tmplocation/cannot-write"
mkdir "$TMPDIR"
chmod ugo-w "$TMPDIR"
virtualenvwrapper_run_hook "initialize" >/dev/null 2>&1
RC=$?
assertSame "Unexpected exit code $RC" "1" "$RC"
chmod ugo+w "$TMPDIR"
rmdir "$TMPDIR"
TMPDIR="$old_tmpdir"
}
. "$test_dir/shunit2"
|