Skip to content

Commit ba2c4ea

Browse files
committed
add test for mkvirtualenv w/ site-packages
Ensure that if the --system-site-packages option is passed properly, the new virtualenv is activated. Fixes issue #189 Signed-off-by: Doug Hellmann <[email protected]>
1 parent e79f556 commit ba2c4ea

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

tests/test_mkvirtualenv.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ GLOBAL postmkvirtualenv"
5151
rm -f "$WORKON_HOME/premkvirtualenv"
5252
rm -f "$WORKON_HOME/postmkvirtualenv"
5353
deactivate
54-
rmvirtualenv "env3"
54+
rmvirtualenv "env3" >/dev/null 2>&1
5555
}
5656

5757
test_no_virtualenv () {
@@ -108,6 +108,28 @@ test_mkvirtualenv_sitepackages () {
108108
rmvirtualenv "env4"
109109
}
110110

111+
test_mkvirtualenv_hooks_system_site_packages () {
112+
# See issue #189
113+
114+
export pre_test_dir=$(cd "$test_dir"; pwd)
115+
116+
echo "#!/bin/sh" > "$WORKON_HOME/premkvirtualenv"
117+
echo "echo GLOBAL premkvirtualenv \`pwd\` \"\$@\" >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/premkvirtualenv"
118+
chmod +x "$WORKON_HOME/premkvirtualenv"
119+
120+
echo "echo GLOBAL postmkvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv"
121+
mkvirtualenv --system-site-packages "env189" >/dev/null 2>&1
122+
output=$(cat "$test_dir/catch_output")
123+
workon_home_as_pwd=$(cd $WORKON_HOME; pwd)
124+
expected="GLOBAL premkvirtualenv $workon_home_as_pwd env189
125+
GLOBAL postmkvirtualenv"
126+
assertSame "$expected" "$output"
127+
rm -f "$WORKON_HOME/premkvirtualenv"
128+
rm -f "$WORKON_HOME/postmkvirtualenv"
129+
deactivate
130+
rmvirtualenv "env189" >/dev/null 2>&1
131+
}
132+
111133
test_mkvirtualenv_args () {
112134
# See issue #102
113135
VIRTUALENVWRAPPER_VIRTUALENV_ARGS="--no-site-packages"

0 commit comments

Comments
 (0)