Skip to content

Commit d9f58ea

Browse files
committed
remove tests and features relying on --no-site-packages
virtualenv dropped the --no-site-packages option. This PR updates the code and tests to remove features related to that missing option. * remove copy tests for --no-site-packages * update test_mktmpenv_virtualenv_args to not need --no-site-packages * update mkvirtualenv tests to not rely on --no-site-packages * remove toggleglobalsitepackages command related to #8
1 parent 04a2c3d commit d9f58ea

File tree

7 files changed

+10
-147
lines changed

7 files changed

+10
-147
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
============================

tests/test_cp.sh

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -137,33 +137,4 @@ GLOBAL postcpvirtualenv"
137137
rm -f "$WORKON_HOME/postmkvirtualenv"
138138
}
139139

140-
test_no_site_packages () {
141-
# See issue #102
142-
mkvirtualenv "source" --no-site-packages >/dev/null 2>&1
143-
cpvirtualenv "source" "destination" >/dev/null 2>&1
144-
ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt"
145-
assertTrue "$ngsp_file does not exist in copied env" "[ -f \"$ngsp_file\" ]"
146-
}
147-
148-
test_no_site_packages_default_args () {
149-
# See issue #102
150-
VIRTUALENVWRAPPER_VIRTUALENV_ARGS="--no-site-packages"
151-
# With the argument, verify that they are not copied.
152-
mkvirtualenv "source" >/dev/null 2>&1
153-
cpvirtualenv "source" "destination" >/dev/null 2>&1
154-
ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt"
155-
assertTrue "$ngsp_file does not exist" "[ -f \"$ngsp_file\" ]"
156-
unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS
157-
}
158-
159-
test_no_site_packages_default_behavior () {
160-
# See issue #102
161-
# virtualenv 1.7 changed to make --no-site-packages the default
162-
mkvirtualenv "source" >/dev/null 2>&1
163-
cpvirtualenv "source" "destination" >/dev/null 2>&1
164-
ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt"
165-
assertTrue "$ngsp_file does not exist in copied env" "[ -f \"$ngsp_file\" ]"
166-
}
167-
168140
. "$test_dir/shunit2"
169-

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_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_toggleglobalsitepackages.sh

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

virtualenvwrapper.sh

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -948,22 +948,6 @@ function lssitepackages {
948948
fi
949949
}
950950

951-
# Toggles the currently-active virtualenv between having and not having
952-
# access to the global site-packages.
953-
#:help:toggleglobalsitepackages: turn access to global site-packages on/off
954-
function toggleglobalsitepackages {
955-
virtualenvwrapper_verify_workon_home || return 1
956-
virtualenvwrapper_verify_active_environment || return 1
957-
typeset no_global_site_packages_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt"
958-
if [ -f $no_global_site_packages_file ]; then
959-
rm $no_global_site_packages_file
960-
[ "$1" = "-q" ] || echo "Enabled global site-packages"
961-
else
962-
touch $no_global_site_packages_file
963-
[ "$1" = "-q" ] || echo "Disabled global site-packages"
964-
fi
965-
}
966-
967951
#:help:cpvirtualenv: duplicate the named virtualenv to make a new one
968952
function cpvirtualenv {
969953
virtualenvwrapper_verify_workon_home || return 1

0 commit comments

Comments
 (0)