Skip to content

Commit 46d8958

Browse files
authored
Merge pull request #21 from dhellmann/fix-all-tests
updates to make CI jobs pass
2 parents 58bb981 + c945ffb commit 46d8958

15 files changed

+89
-184
lines changed

docs/source/command_ref.rst

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -465,36 +465,6 @@ for the environment.
465465

466466
*Based on a contribution from James Bennett and Jannis Leidel.*
467467

468-
.. _command-toggleglobalsitepackages:
469-
470-
toggleglobalsitepackages
471-
------------------------
472-
473-
Controls whether the active virtualenv will access the packages in the
474-
global Python ``site-packages`` directory.
475-
476-
Syntax::
477-
478-
toggleglobalsitepackages [-q]
479-
480-
Outputs the new state of the virtualenv. Use the ``-q`` switch to turn off all
481-
output.
482-
483-
::
484-
485-
$ mkvirtualenv env1
486-
New python executable in env1/bin/python
487-
Installing setuptools.............................................
488-
..................................................................
489-
..................................................................
490-
done.
491-
(env1)$ toggleglobalsitepackages
492-
Disabled global site-packages
493-
(env1)$ toggleglobalsitepackages
494-
Enabled global site-packages
495-
(env1)$ toggleglobalsitepackages -q
496-
(env1)$
497-
498468
============================
499469
Project Directory Management
500470
============================

docs/source/developers.rst

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,29 @@ The test suite for virtualenvwrapper uses shunit2_ and tox_. The
6969
shunit2 source is included in the ``tests`` directory, but tox must be
7070
installed separately (``pip install tox``).
7171

72-
To run the tests under bash, zsh, and ksh for Python 2.7 through 3.6,
73-
run ``tox`` from the top level directory of the hg repository.
72+
To run the tests under bash and zsh for the default Python,
73+
run ``tox`` from the top level directory of the hg repository::
74+
75+
$ tox
7476

7577
To run individual test scripts, use a command like::
7678

77-
$ tox tests/test_cd.sh
79+
$ tox -- tests/test_cd.sh
7880

7981
To run tests under a single version of Python, specify the appropriate
8082
environment when running tox::
8183

82-
$ tox -e py27
84+
$ tox -e py311
8385

8486
Combine the two modes to run specific tests with a single version of
8587
Python::
8688

87-
$ tox -e py27 tests/test_cd.sh
89+
$ tox -e py311 -- tests/test_cd.sh
90+
91+
To stop the test suite as soon as any test fails, use the `fast` tox
92+
target::
93+
94+
$ tox -e fast
8895

8996
Add new tests by modifying an existing file or creating new script in
9097
the ``tests`` directory.

tests/run_tests

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- mode: shell-script -*-
22
#set -x
33

4-
envdir="$1"
4+
envdir="$(cd $1 && pwd)"
55
shift
66
scripts="$*"
77
if [ -z "$scripts" ]
@@ -14,6 +14,9 @@ then
1414
fi
1515
fi
1616

17+
# Override FAIL_FAST to true to exit as soon as any test fails
18+
FAIL_FAST=${FAIL_FAST:-false}
19+
1720
# Force the tox virtualenv to be active.
1821
#
1922
# Since this script runs from within a separate shell created by tox,
@@ -33,7 +36,7 @@ export HOOK_VERBOSE_OPTION
3336

3437
# Force virtualenvwrapper to use the python interpreter in the
3538
# tox-created virtualenv.
36-
VIRTUALENVWRAPPER_PYTHON="$envdir/bin/python"
39+
VIRTUALENVWRAPPER_PYTHON="$envdir/bin/python3"
3740
export VIRTUALENVWRAPPER_PYTHON
3841

3942
# Clear any user settings for the hook directory or log directory
@@ -44,6 +47,7 @@ unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS
4447

4548
# Run the test scripts with a little formatting around them to make it
4649
# easier to find where each script output starts.
50+
RC=0
4751
for test_script in $scripts
4852
do
4953

@@ -66,9 +70,14 @@ do
6670
echo
6771
SHUNIT_PARENT="$test_script"
6872
export SHUNIT_PARENT
69-
$SHELL $test_shell_opts $test_script || exit 1
73+
if ! $SHELL $test_shell_opts $test_script; then
74+
RC=1
75+
if $FAIL_FAST; then
76+
exit $RC
77+
fi
78+
fi
7079
echo
7180

7281
done
7382

74-
exit 0
83+
exit $RC

tests/setup.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,3 @@ 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-
# tox no longer exports these variables by default, so set them
15-
# ourselves to ensure the tests that rely on the values work
16-
export USER=$(id -u -n)
17-
export HOME=$(id -P | cut -f9 -d:)

tests/test_cp.sh

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,6 @@ test_virtualenvwrapper_virtualenv_clone_variable () {
9898
assertTrue "VIRTUALENVWRAPPER_CLONE did not clone fake file" "[ -f $WORKON_HOME/destination/fake_virtualenv_clone_was_here ]"
9999
}
100100

101-
test_source_relocatable () {
102-
mkvirtualenv "source" >/dev/null 2>&1
103-
(cd tests/testpackage && python setup.py install) >/dev/null 2>&1
104-
assertTrue "virtualenv --relocatable \"$WORKON_HOME/source\""
105-
cpvirtualenv "source" "destination" >/dev/null 2>&1
106-
testscript="$(which testscript.py)"
107-
assertTrue "Environment test script not the same as copy" "[ $WORKON_HOME/destination/bin/testscript.py -ef $testscript ]"
108-
assertTrue virtualenvwrapper_verify_active_environment
109-
assertSame "Wrong virtualenv name" "destination" $(basename "$VIRTUAL_ENV")
110-
}
111-
112101
test_source_does_not_exist () {
113102
assertSame "Please provide a valid virtualenv to copy." "$(cpvirtualenv virtualenvthatdoesntexist foo)"
114103
}
@@ -148,33 +137,4 @@ GLOBAL postcpvirtualenv"
148137
rm -f "$WORKON_HOME/postmkvirtualenv"
149138
}
150139

151-
test_no_site_packages () {
152-
# See issue #102
153-
mkvirtualenv "source" --no-site-packages >/dev/null 2>&1
154-
cpvirtualenv "source" "destination" >/dev/null 2>&1
155-
ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt"
156-
assertTrue "$ngsp_file does not exist in copied env" "[ -f \"$ngsp_file\" ]"
157-
}
158-
159-
test_no_site_packages_default_args () {
160-
# See issue #102
161-
VIRTUALENVWRAPPER_VIRTUALENV_ARGS="--no-site-packages"
162-
# With the argument, verify that they are not copied.
163-
mkvirtualenv "source" >/dev/null 2>&1
164-
cpvirtualenv "source" "destination" >/dev/null 2>&1
165-
ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt"
166-
assertTrue "$ngsp_file does not exist" "[ -f \"$ngsp_file\" ]"
167-
unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS
168-
}
169-
170-
test_no_site_packages_default_behavior () {
171-
# See issue #102
172-
# virtualenv 1.7 changed to make --no-site-packages the default
173-
mkvirtualenv "source" >/dev/null 2>&1
174-
cpvirtualenv "source" "destination" >/dev/null 2>&1
175-
ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt"
176-
assertTrue "$ngsp_file does not exist in copied env" "[ -f \"$ngsp_file\" ]"
177-
}
178-
179140
. "$test_dir/shunit2"
180-

tests/test_lazy_loaded.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ test_lssitepackages_defined_normal() {
6464
function_defined_normal lssitepackages
6565
}
6666

67-
test_toggleglobalsitepackages_defined_normal() {
68-
function_defined_normal toggleglobalsitepackages
69-
}
70-
7167
test_cpvirtualenv_defined_normal() {
7268
function_defined_normal cpvirtualenv
7369
}

tests/test_ls.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ test_get_site_packages_dir () {
2727

2828
test_lssitepackages () {
2929
mkvirtualenv "lssitepackagestest" >/dev/null 2>&1
30-
contents="$(lssitepackages)"
31-
assertTrue "did not find easy_install in site-packages" "echo $contents | grep -q easy_install"
30+
contents="$(lssitepackages)"
31+
assertTrue "did not find pip in site-packages: ${contents}" "echo $contents | grep -q pip"
3232
deactivate
3333
}
3434

3535
test_lssitepackages_space_in_name () {
3636
# Only test with leading and internal spaces. Directory names with trailing spaces are legal,
3737
# and work with virtualenv on OSX, but error out on Linux.
3838
mkvirtualenv " space lssitepackagestest" >/dev/null 2>&1
39-
contents="$(lssitepackages)"
40-
assertTrue "did not find easy_install in site-packages" "echo $contents | grep -q easy_install"
39+
contents="$(lssitepackages)"
40+
assertTrue "did not find pip in site-packages: ${contents}" "echo $contents | grep -q pip"
4141
deactivate
4242
}
4343

@@ -46,7 +46,7 @@ test_lssitepackages_add2virtualenv () {
4646
parent_dir=$(dirname $(pwd))
4747
base_dir=$(basename $(pwd))
4848
add2virtualenv "../$base_dir"
49-
contents="$(lssitepackages)"
49+
contents="$(lssitepackages)"
5050
actual=$(echo $contents | grep $base_dir)
5151
expected=$(echo $contents)
5252
assertSame "$expected" "$actual"

tests/test_mktmpenv.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ test_mktmpenv_no_cd() {
4343
}
4444

4545
test_mktmpenv_virtualenv_args() {
46-
mktmpenv --no-site-packages >/dev/null 2>&1
47-
ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt"
48-
assertTrue "$ngsp_file does not exist" "[ -f \"$ngsp_file\" ]"
46+
mktmpenv --without-pip >/dev/null 2>&1
47+
contents="$(lssitepackages)"
48+
assertFalse "found pip in site-packages: ${contents}" "echo $contents | grep -q pip"
4949
}
5050

5151
test_deactivate() {

tests/test_mkvirtualenv.sh

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,6 @@ test_no_workon_home () {
104104
WORKON_HOME="$old_home"
105105
}
106106

107-
test_mkvirtualenv_sitepackages () {
108-
# This part of the test is not reliable because
109-
# creating a new virtualenv from inside the
110-
# tox virtualenv inherits the setting from there.
111-
# # Without the option, verify that site-packages are copied.
112-
# mkvirtualenv "with_sp" >/dev/null 2>&1
113-
# ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt"
114-
# assertFalse "$ngsp_file exists" "[ -f \"$ngsp_file\" ]"
115-
# rmvirtualenv "env3"
116-
117-
# With the argument, verify that they are not copied.
118-
mkvirtualenv --no-site-packages "without_sp" >/dev/null 2>&1
119-
ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt"
120-
assertTrue "$ngsp_file does not exist" "[ -f \"$ngsp_file\" ]"
121-
rmvirtualenv "env4" >/dev/null 2>&1
122-
}
123-
124107
test_mkvirtualenv_hooks_system_site_packages () {
125108
# See issue #189
126109

@@ -143,12 +126,14 @@ GLOBAL postmkvirtualenv"
143126

144127
test_mkvirtualenv_args () {
145128
# See issue #102
146-
VIRTUALENVWRAPPER_VIRTUALENV_ARGS="--no-site-packages"
129+
VIRTUALENVWRAPPER_VIRTUALENV_ARGS="--without-pip"
147130
# With the argument, verify that they are not copied.
148-
mkvirtualenv "without_sp2" >/dev/null 2>&1
149-
ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt"
150-
assertTrue "$ngsp_file does not exist" "[ -f \"$ngsp_file\" ]"
151-
rmvirtualenv "env4" >/dev/null 2>&1
131+
mkvirtualenv "without_pip" >/dev/null 2>&1
132+
local RC=$?
133+
assertTrue "mkvirtualenv failed" "[ $RC -eq 0 ]"
134+
contents="$(lssitepackages)"
135+
assertFalse "found pip in site-packages: ${contents}" "echo $contents | grep -q pip"
136+
rmvirtualenv "without_pip" >/dev/null 2>&1
152137
unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS
153138
}
154139

tests/test_run_hook.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ test_virtualenvwrapper_run_hook_permissions() {
5757
echo "echo run $@ >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/prermvirtualenv"
5858
chmod 0444 "$WORKON_HOME/prermvirtualenv"
5959
touch "$TMPDIR/catch_output"
60-
error=$(virtualenvwrapper_run_hook "pre_rmvirtualenv" "foo" 2>&1 | grep "could not run" | cut -f2- -d'[')
60+
error=$(virtualenvwrapper_run_hook "pre_rmvirtualenv" "foo" 2>&1 | grep "could not run" | cut -f2- -d'[' | cut -f1 -d:)
6161
output=$(cat "$TMPDIR/catch_output")
6262
expected=""
6363
assertSame "$expected" "$output"

tests/test_tempfile.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ setUp () {
2121
}
2222

2323
test_tempfile () {
24+
if [ "$(uname)" = "Darwin" ]; then
25+
# macOS doesn't seem to allow controlling where mktemp creates
26+
# the output files
27+
return 0
28+
fi
2429
filename=$(virtualenvwrapper_tempfile hook)
2530
assertTrue "Filename is empty" "[ ! -z \"$filename\" ]"
2631
assertTrue "File doesn't exist" "[ -f \"$filename\" ]"
@@ -52,6 +57,11 @@ test_bad_mktemp() {
5257
}
5358

5459
test_no_such_tmpdir () {
60+
if [ "$(uname)" = "Darwin" ]; then
61+
# macOS doesn't seem to allow controlling where mktemp creates
62+
# the output files
63+
return 0
64+
fi
5565
old_tmpdir="$TMPDIR"
5666
export TMPDIR="$TMPDIR/does-not-exist"
5767
virtualenvwrapper_run_hook "initialize" >/dev/null 2>&1
@@ -61,6 +71,11 @@ test_no_such_tmpdir () {
6171
}
6272

6373
test_tmpdir_not_writable () {
74+
if [ "$(uname)" = "Darwin" ]; then
75+
# macOS doesn't seem to allow controlling where mktemp creates
76+
# the output files
77+
return 0
78+
fi
6479
old_tmpdir="$TMPDIR"
6580
export TMPDIR="$TMPDIR/cannot-write"
6681
mkdir "$TMPDIR"

tests/test_toggleglobalsitepackages.sh

Lines changed: 0 additions & 43 deletions
This file was deleted.

tests/test_wipeenv.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ test_wipeenv_pip_e () {
3232
mkvirtualenv "wipetest" >/dev/null 2>&1
3333
(cd tests/testpackage && pip install -e .) >/dev/null 2>&1
3434
before="$(pip freeze)"
35-
assertTrue "testpackage not installed" "pip freeze | grep testpackage"
35+
assertTrue "testpackage not installed: $before" "pip freeze | grep testpackage"
3636
wipeenv >/dev/null 2>&1
3737
after="$(pip freeze)"
38-
assertFalse "testpackage still installed" "pip freeze | grep testpackage"
38+
assertFalse "testpackage still installed: $after" "pip freeze | grep testpackage"
3939
}
4040

4141
# test_wipeenv_pip_e_url () {

0 commit comments

Comments
 (0)