Skip to content

Commit 389179c

Browse files
committed
tests: update tests to use the packaged version of the scripts
The tests were always running the local source copy of virtualenvwrapper.sh, which does not ensure we are packaging and installing that file properly. This commit changes the logic for loading the wrappers so when the job is running under tox we always look in the virtualenv's bin directory.
1 parent 13e8068 commit 389179c

35 files changed

+56
-39
lines changed

tests/setup.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,19 @@ export WORKON_HOME=$(mktemp -d -t "WORKON_HOME.XXXX.$$")
1010
export PROJECT_HOME=$(mktemp -d -t "PROJECT_HOME.XXXX.$$")
1111

1212
#unset HOOK_VERBOSE_OPTION
13+
14+
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
15+
16+
# This should point to VIRTUAL_ENV/bin when running under tox.
17+
TEST_BIN_DIR=$(dirname $(which python))
18+
19+
load_wrappers() {
20+
if [ "$USING_TOX" = "1" ]; then
21+
# Use the version of the scripts installed as part of the
22+
# package.
23+
source "$TEST_BIN_DIR/virtualenvwrapper.sh"
24+
else
25+
echo "USING SOURCE VERSION OF SCRIPT"
26+
source "$SCRIPTDIR/../virtualenvwrapper.sh"
27+
fi
28+
}

tests/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ source "$test_dir/setup.sh"
66
oneTimeSetUp() {
77
rm -rf "$WORKON_HOME"
88
mkdir -p "$WORKON_HOME"
9-
source "$test_dir/../virtualenvwrapper.sh"
9+
load_wrappers
1010
}
1111

1212
oneTimeTearDown() {

tests/test_add2virtualenv.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ source "$test_dir/setup.sh"
66
oneTimeSetUp() {
77
rm -rf "$WORKON_HOME"
88
mkdir -p "$WORKON_HOME"
9-
source "$test_dir/../virtualenvwrapper.sh" >/dev/null 2>&1
9+
load_wrappers >/dev/null 2>&1
1010
}
1111

1212
oneTimeTearDown() {

tests/test_allvirtualenv.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ source "$test_dir/setup.sh"
66
oneTimeSetUp() {
77
rm -rf "$WORKON_HOME"
88
mkdir -p "$WORKON_HOME"
9+
load_wrappers
910
unset VIRTUAL_ENV
10-
source "$test_dir/../virtualenvwrapper.sh"
1111
# These three env names must sort the same whether the OS considers leading whitespace or not.
1212
# "test" is after " env" and after "env", so the asserts work on OSX and Linux.
1313
mkvirtualenv test1 >/dev/null 2>&1

tests/test_cd.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ source "$test_dir/setup.sh"
66
oneTimeSetUp() {
77
rm -rf "$WORKON_HOME"
88
mkdir -p "$WORKON_HOME"
9+
load_wrappers
910
unset VIRTUAL_ENV
10-
source "$test_dir/../virtualenvwrapper.sh"
1111
mkvirtualenv cd-test >/dev/null 2>&1
1212
deactivate
1313
}

tests/test_cd_alias.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ source "$test_dir/setup.sh"
66
oneTimeSetUp() {
77
rm -rf "$WORKON_HOME"
88
mkdir -p "$WORKON_HOME"
9+
load_wrappers
910
unset VIRTUAL_ENV
10-
source "$test_dir/../virtualenvwrapper.sh"
1111
mkvirtualenv cd-test >/dev/null 2>&1
1212
deactivate
1313
}

tests/test_cd_space_in_name.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ oneTimeSetUp() {
77
export WORKON_HOME="$WORKON_HOME/ this has spaces"
88
rm -rf "$WORKON_HOME"
99
mkdir -p "$WORKON_HOME"
10+
load_wrappers
1011
unset VIRTUAL_ENV
11-
source "$test_dir/../virtualenvwrapper.sh"
1212
# Only test with leading and internal spaces. Directory names with trailing spaces are legal,
1313
# and work with virtualenv on OSX, but error out on Linux.
1414
mkvirtualenv " env with space" >/dev/null 2>&1

tests/test_cp.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ source "$test_dir/setup.sh"
66
setUp () {
77
rm -rf "$WORKON_HOME"
88
mkdir -p "$WORKON_HOME"
9-
source "$test_dir/../virtualenvwrapper.sh"
9+
load_wrappers
1010
rm -f "$TMPDIR/catch_output"
1111
echo
1212
}
1313

1414
tearDown() {
1515
if type deactivate >/dev/null 2>&1
16-
then
16+
then
1717
deactivate
1818
fi
1919
rm -rf "$WORKON_HOME"

tests/test_cpvirtualenv.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ source "$test_dir/setup.sh"
66
setUp () {
77
rm -rf "$WORKON_HOME"
88
mkdir -p "$WORKON_HOME"
9-
source "$test_dir/../virtualenvwrapper.sh"
9+
load_wrappers
1010
echo
1111
}
1212

tests/test_deactivate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ source "$test_dir/setup.sh"
66
oneTimeSetUp() {
77
rm -rf "$WORKON_HOME"
88
mkdir -p "$WORKON_HOME"
9-
source "$test_dir/../virtualenvwrapper.sh"
9+
load_wrappers
1010
mkvirtualenv "env1"
1111
}
1212

0 commit comments

Comments
 (0)