|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +#set -x |
| 4 | + |
| 5 | +test_dir=$(dirname $0) |
| 6 | +source "$test_dir/../virtualenvwrapper_bashrc" |
| 7 | + |
| 8 | +export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" |
| 9 | + |
| 10 | +oneTimeSetUp() { |
| 11 | + rm -rf "$WORKON_HOME" |
| 12 | + mkdir -p "$WORKON_HOME" |
| 13 | +} |
| 14 | + |
| 15 | +oneTimeTearDown() { |
| 16 | + rm -rf "$WORKON_HOME" |
| 17 | +} |
| 18 | + |
| 19 | +setUp () { |
| 20 | + echo |
| 21 | + rm -f "$test_dir/catch_output" |
| 22 | +} |
| 23 | + |
| 24 | +test_cdvirtual() { |
| 25 | + pushd "$(pwd)" >/dev/null |
| 26 | + cdvirtualenv |
| 27 | + assertSame "$VIRTUAL_ENV" "$(pwd)" |
| 28 | + cdvirtualenv bin |
| 29 | + assertSame "$VIRTUAL_ENV/bin" "$(pwd)" |
| 30 | + popd >/dev/null |
| 31 | +} |
| 32 | + |
| 33 | +test_cdsitepackages () { |
| 34 | + pushd "$(pwd)" >/dev/null |
| 35 | + cdsitepackages |
| 36 | + pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) |
| 37 | + sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" |
| 38 | + assertSame "$sitepackages" "$(pwd)" |
| 39 | + popd >/dev/null |
| 40 | +} |
| 41 | + |
| 42 | +test_cdsitepackages_with_arg () { |
| 43 | + pushd "$(pwd)" >/dev/null |
| 44 | + pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) |
| 45 | + sitepackage_subdir="$VIRTUAL_ENV/lib/python${pyvers}/site-packages/subdir" |
| 46 | + mkdir -p "${sitepackage_subdir}" |
| 47 | + cdsitepackages subdir |
| 48 | + assertSame "$sitepackage_subdir" "$(pwd)" |
| 49 | + popd >/dev/null |
| 50 | +} |
| 51 | + |
| 52 | +test_cdvirtualenv_no_workon_home () { |
| 53 | + old_home="$WORKON_HOME" |
| 54 | + export WORKON_HOME="$WORKON_HOME/not_there" |
| 55 | + output=`cdvirtualenv 2>&1` |
| 56 | + assertTrue "Did not see expected message" "echo $output | grep 'does not exist'" |
| 57 | + WORKON_HOME="$old_home" |
| 58 | +} |
| 59 | + |
| 60 | +test_cdsitepackages_no_workon_home () { |
| 61 | + old_home="$WORKON_HOME" |
| 62 | + export WORKON_HOME="$WORKON_HOME/not_there" |
| 63 | + output=`cdsitepackages 2>&1` |
| 64 | + assertTrue "Did not see expected message" "echo $output | grep 'does not exist'" |
| 65 | + WORKON_HOME="$old_home" |
| 66 | +} |
| 67 | + |
| 68 | + |
| 69 | +. "$test_dir/shunit2" |
0 commit comments