Skip to content

Commit fd109f6

Browse files
committed
fix #42 by quieting the errors/warnings
1 parent b216a86 commit fd109f6

File tree

5 files changed

+72
-37
lines changed

5 files changed

+72
-37
lines changed

ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
2010-04-29 Doug Hellmann <[email protected]>
22

3+
* tests/test_workon.sh: Refactor deactivate tests into their own
4+
script.
5+
6+
* tests/test_deactivate.sh: Refactor deactivate tests into their
7+
own script.
8+
39
* virtualenvwrapper.sh (virtualenvwrapper_get_python_version): Add
410
a comment about why we're using the $PATH python instead of the
511
one where the wrappers are installed.
612
(add2virtualenv): Use the install-tree python instead of the one
713
from $PATH.
14+
(deactivate): Ignore errors from redundant unset calls.
815

916
2010-04-26 Doug Hellmann <[email protected]>
1017

docs/en/history.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ Dev
1111
- Fixed improper use of python from ``$PATH`` instead of the
1212
location where the wrappers are installed. See `issue #41
1313
<http://bitbucket.org/dhellmann/virtualenvwrapper/issue/41/>`__.
14+
- Quiet spurrious error/warning messages when deactivating a
15+
virtualenv under zsh. See `issue #42
16+
<http://bitbucket.org/dhellmann/virtualenvwrapper/issue/42/>`__.
1417

1518
2.1
1619

tests/test_deactivate.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/sh
2+
3+
#set -x
4+
5+
test_dir=$(dirname $0)
6+
7+
export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME"
8+
9+
oneTimeSetUp() {
10+
rm -rf "$WORKON_HOME"
11+
mkdir -p "$WORKON_HOME"
12+
source "$test_dir/../virtualenvwrapper.sh"
13+
mkvirtualenv "env1"
14+
}
15+
16+
oneTimeTearDown() {
17+
rm -rf "$WORKON_HOME"
18+
}
19+
20+
setUp () {
21+
echo
22+
rm -f "$test_dir/catch_output"
23+
}
24+
25+
test_deactivate () {
26+
workon env1
27+
assertNotNull "$VIRTUAL_ENV"
28+
deactivate
29+
assertNull "$VIRTUAL_ENV"
30+
assertFalse virtualenvwrapper_verify_active_environment
31+
}
32+
33+
test_deactivate_hooks () {
34+
workon env1
35+
36+
for t in pre post
37+
do
38+
echo "echo GLOBAL ${t}deactivate \$VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV >> $test_dir/catch_output" > "$WORKON_HOME/${t}deactivate"
39+
echo "echo ENV ${t}deactivate \$VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV >> $test_dir/catch_output" > "$WORKON_HOME/env1/bin/${t}deactivate"
40+
done
41+
42+
touch "$test_dir/catch_output"
43+
44+
deactivate
45+
46+
output=$(cat "$test_dir/catch_output")
47+
expected="ENV predeactivate
48+
GLOBAL predeactivate
49+
ENV postdeactivate $WORKON_HOME/env1
50+
GLOBAL postdeactivate $WORKON_HOME/env1"
51+
assertSame "$expected" "$output"
52+
53+
for t in pre post
54+
do
55+
rm -f "$WORKON_HOME/env1/bin/${t}activate"
56+
rm -f "$WORKON_HOME/${t}activate"
57+
done
58+
}
59+
60+
. "$test_dir/shunit2"

tests/test_workon.sh

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -57,41 +57,6 @@ ENV postactivate"
5757
done
5858
}
5959

60-
test_deactivate () {
61-
workon env1
62-
assertNotNull "$VIRTUAL_ENV"
63-
deactivate
64-
assertNull "$VIRTUAL_ENV"
65-
assertFalse virtualenvwrapper_verify_active_environment
66-
}
67-
68-
test_deactivate_hooks () {
69-
workon env1
70-
71-
for t in pre post
72-
do
73-
echo "echo GLOBAL ${t}deactivate \$VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV >> $test_dir/catch_output" > "$WORKON_HOME/${t}deactivate"
74-
echo "echo ENV ${t}deactivate \$VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV >> $test_dir/catch_output" > "$WORKON_HOME/env1/bin/${t}deactivate"
75-
done
76-
77-
touch "$test_dir/catch_output"
78-
79-
deactivate
80-
81-
output=$(cat "$test_dir/catch_output")
82-
expected="ENV predeactivate
83-
GLOBAL predeactivate
84-
ENV postdeactivate $WORKON_HOME/env1
85-
GLOBAL postdeactivate $WORKON_HOME/env1"
86-
assertSame "$expected" "$output"
87-
88-
for t in pre post
89-
do
90-
rm -f "$WORKON_HOME/env1/bin/${t}activate"
91-
rm -f "$WORKON_HOME/${t}activate"
92-
done
93-
}
94-
9560
test_virtualenvwrapper_show_workon_options () {
9661
mkdir "$WORKON_HOME/not_env"
9762
(cd "$WORKON_HOME"; ln -s env1 link_env)

virtualenvwrapper.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ workon () {
262262
if [ ! "$1" = "nondestructive" ]
263263
then
264264
# Remove this function
265-
unset -f virtualenv_deactivate
266-
unset -f deactivate
265+
unset -f virtualenv_deactivate >/dev/null 2>&1
266+
unset -f deactivate >/dev/null 2>&1
267267
fi
268268
269269
}'

0 commit comments

Comments
 (0)