Skip to content

Commit 63ca657

Browse files
committed
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 fe125c8 commit 63ca657

36 files changed

+1357
-40
lines changed

docs/source/history.rst

Lines changed: 1301 additions & 1 deletion
Large diffs are not rendered by default.

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

tests/test_derive_workon_home.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ TMP_WORKON_HOME="$WORKON_HOME"
77
oneTimeSetUp() {
88
rm -rf "$TMP_WORKON_HOME"
99
mkdir -p "$TMP_WORKON_HOME"
10-
source "$test_dir/../virtualenvwrapper.sh"
10+
load_wrappers
1111
echo $PYTHONPATH
1212
}
1313

tests/test_dir_stack.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ oneTimeTearDown() {
1414
setUp () {
1515
rm -rf "$WORKON_HOME"
1616
mkdir -p "$WORKON_HOME"
17-
source "$test_dir/../virtualenvwrapper.sh"
17+
load_wrappers
1818
mkdir "$WORKON_HOME/start_here"
1919
mkdir "$WORKON_HOME/on_the_stack"
2020
echo

tests/test_expandpath.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ source "$test_dir/setup.sh"
55
TMP_WORKON_HOME="$WORKON_HOME"
66

77
oneTimeSetUp() {
8-
source "$test_dir/../virtualenvwrapper.sh"
8+
load_wrappers
99
echo $PYTHONPATH
1010
}
1111

tests/test_hook_dir.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ RUN_SCRIPTS="premkvirtualenv prermvirtualenv postrmvirtualenv preactivate get_en
2323

2424
test_virtualenvwrapper_initialize() {
2525
export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME/hooks"
26-
source "$test_dir/../virtualenvwrapper.sh"
26+
load_wrappers
2727
for hook in $SOURCE_SCRIPTS
2828
do
2929
assertTrue "Global $WORKON_HOME/$hook was not created" "[ -f $WORKON_HOME/hooks/$hook ]"

tests/test_log_file.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ setUp () {
99

1010
test_set_by_user() {
1111
export VIRTUALENVWRAPPER_LOG_FILE="$WORKON_HOME/hooks.log"
12-
source "$test_dir/../virtualenvwrapper.sh"
12+
load_wrappers
1313
assertTrue "Log file was not created" "[ -f $VIRTUALENVWRAPPER_LOG_FILE ]"
1414
}
1515

1616
test_file_permissions() {
1717
export VIRTUALENVWRAPPER_LOG_FILE="$WORKON_HOME/hooks.log"
18-
source "$test_dir/../virtualenvwrapper.sh"
18+
load_wrappers
1919
perms=$(ls -l "$VIRTUALENVWRAPPER_LOG_FILE" | cut -f1 -d' ')
2020
#echo $perms
2121
assertTrue "Log file permissions are wrong: $perms" "echo $perms | grep '^-rw-rw'"
@@ -25,7 +25,7 @@ test_not_set_by_user() {
2525
unset WORKON_HOME
2626
unset VIRTUALENVWRAPPER_LOG_FILE
2727
unset VIRTUALENVWRAPPER_HOOK_DIR
28-
source "$test_dir/../virtualenvwrapper.sh"
28+
load_wrappers
2929
assertSame "" "$VIRTUALENVWRAPPER_LOG_FILE"
3030
}
3131

tests/test_ls.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_mktmpenv.sh

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

1313
oneTimeTearDown() {

tests/test_mkvirtualenv.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_mkvirtualenv_associate.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_mkvirtualenv_install.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_mkvirtualenv_requirements.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_project.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ setUp () {
2121
}
2222

2323
test_initialize() {
24-
source "$test_dir/../virtualenvwrapper.sh"
24+
load_wrappers
2525
for hook in premkproject postmkproject
2626
do
2727
assertTrue "Global $hook was not created" "[ -f $WORKON_HOME/$hook ]"
@@ -32,7 +32,7 @@ test_initialize() {
3232
test_initialize_hook_dir() {
3333
export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME/hooks"
3434
mkdir -p "$VIRTUALENVWRAPPER_HOOK_DIR"
35-
source "$test_dir/../virtualenvwrapper.sh"
35+
load_wrappers
3636
for hook in premkproject postmkproject
3737
do
3838
assertTrue "Global $hook was not created" "[ -f $VIRTUALENVWRAPPER_HOOK_DIR/$hook ]"

tests/test_project_activate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ oneTimeSetUp() {
88
mkdir -p "$WORKON_HOME"
99
rm -rf "$PROJECT_HOME"
1010
mkdir -p "$PROJECT_HOME"
11-
source "$test_dir/../virtualenvwrapper.sh"
11+
load_wrappers
1212
}
1313

1414
# oneTimeTearDown() {

tests/test_project_cd.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ oneTimeSetUp() {
88
mkdir -p "$WORKON_HOME"
99
rm -rf "$PROJECT_HOME"
1010
mkdir -p "$PROJECT_HOME"
11-
source "$test_dir/../virtualenvwrapper.sh"
11+
load_wrappers
1212
}
1313

1414
oneTimeTearDown() {

tests/test_project_mk.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ oneTimeSetUp() {
99
rm -rf "$PROJECT_HOME"
1010
mkdir -p "$PROJECT_HOME"
1111
export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME/hooks"
12-
source "$test_dir/../virtualenvwrapper.sh"
12+
load_wrappers
1313
}
1414

1515
oneTimeTearDown() {

tests/test_project_templates.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ oneTimeSetUp() {
99
mkdir -p "$WORKON_HOME"
1010
rm -rf "$PROJECT_HOME"
1111
mkdir -p "$PROJECT_HOME"
12-
source "$test_dir/../virtualenvwrapper.sh"
12+
load_wrappers
1313
}
1414

1515
oneTimeTearDown() {

tests/test_rmvirtualenv.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_run_hook.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_setvirtualenvproject.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ oneTimeSetUp() {
88
mkdir -p "$WORKON_HOME"
99
rm -rf "$PROJECT_HOME"
1010
mkdir -p "$PROJECT_HOME"
11-
source "$test_dir/../virtualenvwrapper.sh"
11+
load_wrappers
1212
}
1313

1414
oneTimeTearDown() {

tests/test_support.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_tempfile.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ source "$test_dir/setup.sh"
88
oneTimeSetUp() {
99
rm -rf "$WORKON_HOME"
1010
mkdir -p "$WORKON_HOME"
11-
source "$test_dir/../virtualenvwrapper.sh"
11+
load_wrappers
1212
echo $PYTHONPATH
1313
}
1414

tests/test_virtualenvwrapper.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ setUp () {
2121
}
2222

2323
test_virtualenvwrapper_script_set() {
24-
source "$test_dir/../virtualenvwrapper.sh"
24+
load_wrappers
2525
assertTrue "VIRTUALENVWRAPPER_SCRIPT is not right: $VIRTUALENVWRAPPER_SCRIPT" \
2626
"echo $VIRTUALENVWRAPPER_SCRIPT | grep -q /virtualenvwrapper.sh"
2727
}

tests/test_wipeenv.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_workon.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 "test1" >/dev/null 2>&1
1111
mkvirtualenv "test2" >/dev/null 2>&1
1212
# Only test with leading and internal spaces. Directory names with trailing spaces are legal,

tox.ini

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ pass_env =
77
HOME
88
USER
99
setenv =
10-
TOXIC = true
10+
USING_TOX = 1
1111
SHELL = /bin/bash
1212
allowlist_externals =
1313
bash
1414
zsh
1515

1616
[testenv:fast]
1717
setenv =
18-
TOXIC = true
18+
USING_TOX = 1
1919
SHELL = /bin/bash
2020
FAIL_FAST = true
2121

@@ -25,6 +25,7 @@ commands = flake8 virtualenvwrapper docs/source/conf.py
2525

2626
[testenv:zsh]
2727
setenv =
28+
USING_TOX = 1
2829
SHELL = /bin/zsh
2930
test_shell_opts = -o shwordsplit
3031
commands = zsh -o shwordsplit ./tests/run_tests {envdir} []

0 commit comments

Comments
 (0)