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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
#!/bin/sh
test_dir=$(cd $(dirname $0) && pwd)
source "$test_dir/setup.sh"
oneTimeSetUp() {
rm -rf "$WORKON_HOME"
mkdir -p "$WORKON_HOME"
unset VIRTUAL_ENV
source "$test_dir/../virtualenvwrapper.sh"
mkvirtualenv cd-test
deactivate
}
oneTimeTearDown() {
rm -rf "$WORKON_HOME"
}
setUp () {
echo
rm -f "$test_dir/catch_output"
workon cd-test
}
tearDown () {
deactivate >/dev/null 2>&1
}
test_cdvirtual() {
start_dir="$(pwd)"
cdvirtualenv
assertSame "$VIRTUAL_ENV" "$(pwd)"
cdvirtualenv bin
assertSame "$VIRTUAL_ENV/bin" "$(pwd)"
cd "$start_dir"
}
test_cdsitepackages () {
start_dir="$(pwd)"
cdsitepackages
pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.)
sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages"
assertSame "$sitepackages" "$(pwd)"
cd "$start_dir"
}
test_cdsitepackages_with_arg () {
start_dir="$(pwd)"
pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.)
sitepackage_subdir="$VIRTUAL_ENV/lib/python${pyvers}/site-packages/subdir"
mkdir -p "${sitepackage_subdir}"
cdsitepackages subdir
assertSame "$sitepackage_subdir" "$(pwd)"
cd "$start_dir"
}
test_cdvirtualenv_no_workon_home () {
old_home="$WORKON_HOME"
export WORKON_HOME="$WORKON_HOME/not_there"
cdvirtualenv >"$old_home/output" 2>&1
output=$(cat "$old_home/output")
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"
assertFalse "Was able to change to site-packages" cdsitepackages
assertSame "$old_home" "$(pwd)"
WORKON_HOME="$old_home"
}
. "$test_dir/shunit2"
|