Skip to content

Commit 63b7caf

Browse files
committed
break up the tests to make it easier to run only part of them
--HG-- rename : tests/test_install.sh => tests/manual_test_install.sh
1 parent 4a44aa9 commit 63b7caf

10 files changed

+472
-257
lines changed

pavement.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,13 @@ def test_install(options):
192192

193193
@task
194194
def test():
195-
for shell_cmd in [ 'bash', 'sh', 'SHUNIT_PARENT=./tests/test.sh zsh -o shwordsplit' ]:
196-
sh('%s ./tests/test.sh' % shell_cmd)
197-
sh('%s ./tests/test_misconfigured.sh' % shell_cmd)
195+
#test_scripts = glob.glob('./tests/test*.sh')
196+
test_scripts = path('tests').glob('test*.sh')
197+
for shell_cmd in [ 'bash', 'sh', 'SHUNIT_PARENT=%(test_script)s zsh -o shwordsplit' ]:
198+
for test_script in test_scripts:
199+
base_cmd = shell_cmd + ' %(test_script)s'
200+
cmd = base_cmd % locals()
201+
print '*' * 80
202+
print
203+
sh(cmd)
198204
return

tests/test_install.sh renamed to tests/manual_test_install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ version="$2"
99

1010
export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME"
1111
mkvirtualenv "installtest"
12-
easy_install "$dist_dir/virtualenvwrapper-$version.tar.gz"
12+
pip install "$dist_dir/virtualenvwrapper-$version.tar.gz"
1313
RC=$?
1414

1515
rm -rf "$WORKON_HOME"

tests/test.sh

Lines changed: 0 additions & 253 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@ setUp () {
2121
rm -f "$test_dir/catch_output"
2222
}
2323

24-
test_mkvirtualenv() {
25-
mkvirtualenv "env1"
26-
assertTrue "Environment directory was not created" "[ -d $WORKON_HOME/env1 ]"
27-
for hook in postactivate predeactivate postdeactivate
28-
do
29-
assertTrue "env1 $hook was not created" "[ -f $WORKON_HOME/env1/bin/$hook ]"
30-
assertTrue "env1 $hook is not executable" "[ -x $WORKON_HOME/env1/bin/$hook ]"
31-
done
32-
}
33-
3424
test_virtualenvwrapper_initialize() {
3525
virtualenvwrapper_initialize
3626
for hook in premkvirtualenv postmkvirtualenv prermvirtualenv postrmvirtualenv preactivate postactivate predeactivate postdeactivate
@@ -40,254 +30,11 @@ test_virtualenvwrapper_initialize() {
4030
done
4131
}
4232

43-
test_virtualenvwrapper_run_hook() {
44-
echo "echo run >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/test_hook"
45-
chmod +x "$WORKON_HOME/test_hook"
46-
virtualenvwrapper_run_hook "$WORKON_HOME/test_hook"
47-
output=$(cat "$test_dir/catch_output")
48-
expected="run"
49-
assertSame "$expected" "$output"
50-
}
51-
52-
test_virtualenvwrapper_run_hook_permissions() {
53-
echo "echo run >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/test_hook"
54-
chmod -x "$WORKON_HOME/test_hook"
55-
virtualenvwrapper_run_hook "$WORKON_HOME/test_hook"
56-
output=$(cat "$test_dir/catch_output")
57-
expected=""
58-
assertSame "$expected" "$output"
59-
}
60-
6133
test_get_python_version() {
6234
expected=$(python -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d.)
6335
actual=$(virtualenvwrapper_get_python_version)
6436
assertSame "$expected" "$actual"
6537
}
6638

67-
test_cdvirtual() {
68-
pushd "$(pwd)" >/dev/null
69-
cdvirtualenv
70-
assertSame "$VIRTUAL_ENV" "$(pwd)"
71-
cdvirtualenv bin
72-
assertSame "$VIRTUAL_ENV/bin" "$(pwd)"
73-
popd >/dev/null
74-
}
75-
76-
test_cdsitepackages () {
77-
pushd "$(pwd)" >/dev/null
78-
cdsitepackages
79-
pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.)
80-
sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages"
81-
assertSame "$sitepackages" "$(pwd)"
82-
popd >/dev/null
83-
}
84-
85-
test_cdsitepackages_with_arg () {
86-
pushd "$(pwd)" >/dev/null
87-
pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.)
88-
sitepackage_subdir="$VIRTUAL_ENV/lib/python${pyvers}/site-packages/subdir"
89-
mkdir -p "${sitepackage_subdir}"
90-
cdsitepackages subdir
91-
assertSame "$sitepackage_subdir" "$(pwd)"
92-
popd >/dev/null
93-
}
94-
95-
test_mkvirtualenv_activates () {
96-
mkvirtualenv "env2"
97-
assertTrue virtualenvwrapper_verify_active_environment
98-
assertSame "env2" $(basename "$VIRTUAL_ENV")
99-
}
100-
101-
test_mkvirtualenv_hooks () {
102-
export pre_test_dir=$(cd "$test_dir"; pwd)
103-
echo "echo GLOBAL premkvirtualenv >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/premkvirtualenv"
104-
chmod +x "$WORKON_HOME/premkvirtualenv"
105-
echo "echo GLOBAL postmkvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv"
106-
mkvirtualenv "env3"
107-
output=$(cat "$test_dir/catch_output")
108-
expected="GLOBAL premkvirtualenv
109-
GLOBAL postmkvirtualenv"
110-
assertSame "$expected" "$output"
111-
rm -f "$WORKON_HOME/premkvirtualenv"
112-
rm -f "$WORKON_HOME/postmkvirtualenv"
113-
deactivate
114-
rmvirtualenv "env3"
115-
}
116-
117-
test_no_virtualenv () {
118-
old_path="$PATH"
119-
PATH="/usr/bin:/usr/local/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$HOME/bin"
120-
mkvirtualenv should_not_be_created # 2>/dev/null
121-
RC=$?
122-
# Restore the path before testing because
123-
# the test script depends on commands in the
124-
# path.
125-
export PATH="$old_path"
126-
assertSame "$RC" "1"
127-
}
128-
129-
# test_mkvirtualenv_sitepackages () {
130-
# # Without the option verify that site-packages are copied.
131-
# mkvirtualenv "env3"
132-
# assertSame "env3" "$(basename $VIRTUAL_ENV)"
133-
# pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.)
134-
# sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages"
135-
# #cat "$sitepackages/easy-install.pth"
136-
# assertTrue "Do not have expected virtualenv.py" "[ -f $sitepackages/virtualenv.py ]"
137-
# rmvirtualenv "env3"
138-
#
139-
# # With the argument, verify that they are not copied.
140-
# mkvirtualenv --no-site-packages "env4"
141-
# assertSame "env4" $(basename "$VIRTUAL_ENV")
142-
# pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.)
143-
# sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages"
144-
# assertTrue "[ -f $sitepackages/setuptools.pth ]"
145-
# assertTrue "[ -f $sitepackages/easy-install.pth ]"
146-
# assertFalse "Have virtualenv.py but should not" "[ -f $sitepackages/virtualenv.py ]"
147-
# rmvirtualenv "env4"
148-
# }
149-
150-
test_workon () {
151-
workon env1
152-
assertTrue virtualenvwrapper_verify_active_environment
153-
assertSame "env1" $(basename "$VIRTUAL_ENV")
154-
}
155-
156-
test_workon_activate_hooks () {
157-
for t in pre post
158-
do
159-
echo "echo GLOBAL ${t}activate >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/${t}activate"
160-
chmod +x "$WORKON_HOME/${t}activate"
161-
echo "echo ENV ${t}activate >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/env1/bin/${t}activate"
162-
chmod +x "$WORKON_HOME/env1/bin/${t}activate"
163-
done
164-
165-
rm "$test_dir/catch_output"
166-
167-
workon env1
168-
169-
output=$(cat "$test_dir/catch_output")
170-
expected="GLOBAL preactivate
171-
ENV preactivate
172-
GLOBAL postactivate
173-
ENV postactivate"
174-
175-
assertSame "$expected" "$output"
176-
177-
for t in pre post
178-
do
179-
rm -f "$WORKON_HOME/env1/bin/${t}activate"
180-
rm -f "$WORKON_HOME/${t}activate"
181-
done
182-
}
183-
184-
test_deactivate () {
185-
workon env1
186-
assertNotNull "$VIRTUAL_ENV"
187-
deactivate
188-
assertNull "$VIRTUAL_ENV"
189-
assertFalse virtualenvwrapper_verify_active_environment
190-
}
191-
192-
test_deactivate_hooks () {
193-
workon env1
194-
195-
for t in pre post
196-
do
197-
echo "echo GLOBAL ${t}deactivate >> $test_dir/catch_output" > "$WORKON_HOME/${t}deactivate"
198-
echo "echo ENV ${t}deactivate >> $test_dir/catch_output" > "$WORKON_HOME/env1/bin/${t}deactivate"
199-
done
200-
201-
deactivate
202-
203-
output=$(cat "$test_dir/catch_output")
204-
expected="ENV predeactivate
205-
GLOBAL predeactivate
206-
ENV postdeactivate
207-
GLOBAL postdeactivate"
208-
assertSame "$expected" "$output"
209-
210-
for t in pre post
211-
do
212-
rm -f "$WORKON_HOME/env1/bin/${t}activate"
213-
rm -f "$WORKON_HOME/${t}activate"
214-
done
215-
}
216-
217-
test_virtualenvwrapper_show_workon_options () {
218-
mkdir "$WORKON_HOME/not_env"
219-
(cd "$WORKON_HOME"; ln -s env1 link_env)
220-
envs=$(virtualenvwrapper_show_workon_options | tr '\n' ' ')
221-
assertSame "env1 env2 link_env " "$envs"
222-
rmdir "$WORKON_HOME/not_env"
223-
rm -f "$WORKON_HOME/link_env"
224-
}
225-
226-
test_virtualenvwrapper_show_workon_options_no_envs () {
227-
old_home="$WORKON_HOME"
228-
export WORKON_HOME=${TMPDIR:-/tmp}/$$
229-
envs=$(virtualenvwrapper_show_workon_options 2>/dev/null | tr '\n' ' ')
230-
assertSame "" "$envs"
231-
export WORKON_HOME="$old_home"
232-
}
233-
234-
test_rmvirtualenv () {
235-
mkvirtualenv "deleteme"
236-
assertTrue "[ -d $WORKON_HOME/deleteme ]"
237-
deactivate
238-
rmvirtualenv "deleteme"
239-
assertFalse "[ -d $WORKON_HOME/deleteme ]"
240-
}
241-
242-
test_rmvirtualenv_no_such_env () {
243-
assertFalse "[ -d $WORKON_HOME/deleteme ]"
244-
assertTrue "rmvirtualenv deleteme"
245-
}
246-
247-
test_missing_workon_home () {
248-
save_home="$WORKON_HOME"
249-
WORKON_HOME="/tmp/NO_SUCH_WORKON_HOME"
250-
assertFalse "workon"
251-
assertFalse "mkvirtualenv foo"
252-
assertFalse "rmvirtualenv foo"
253-
assertFalse "lssitepackages"
254-
WORKON_HOME="$save_home"
255-
}
256-
257-
test_add2virtualenv () {
258-
mkvirtualenv "pathtest"
259-
add2virtualenv "/full/path"
260-
cdsitepackages
261-
path_file="./virtualenv_path_extensions.pth"
262-
assertTrue "No /full/path in `cat $path_file`" "grep /full/path $path_file"
263-
cd -
264-
}
265-
266-
test_add2virtualenv_relative () {
267-
mkvirtualenv "pathtest"
268-
parent_dir=$(dirname $(pwd))
269-
base_dir=$(basename $(pwd))
270-
add2virtualenv "../$base_dir"
271-
cdsitepackages
272-
path_file="./virtualenv_path_extensions.pth"
273-
assertTrue "No $parent_dir/$base_dir in \"`cat $path_file`\"" "grep \"$parent_dir/$base_dir\" $path_file"
274-
cd - >/dev/null 2>&1
275-
}
276-
277-
test_lssitepackages () {
278-
mkvirtualenv "lssitepackagestest"
279-
contents="$(lssitepackages)"
280-
assertTrue "No easy-install.pth in $contents" "echo $contents | grep easy-install.pth"
281-
}
282-
283-
test_lssitepackages_add2virtualenv () {
284-
mkvirtualenv "lssitepackagestest"
285-
parent_dir=$(dirname $(pwd))
286-
base_dir=$(basename $(pwd))
287-
add2virtualenv "../$base_dir"
288-
contents="$(lssitepackages)"
289-
assertTrue "No $base_dir in $contents" "echo $contents | grep $base_dir"
290-
}
291-
29239

29340
. "$test_dir/shunit2"

tests/test_add2virtualenv.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/sh
2+
3+
#set -x
4+
5+
test_dir=$(dirname $0)
6+
source "$test_dir/../virtualenvwrapper_bashrc"
7+
8+
export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME"
9+
10+
oneTimeSetUp() {
11+
rm -rf "$WORKON_HOME"
12+
mkdir -p "$WORKON_HOME"
13+
}
14+
15+
oneTimeTearDown() {
16+
rm -rf "$WORKON_HOME"
17+
}
18+
19+
setUp () {
20+
echo
21+
rm -f "$test_dir/catch_output"
22+
}
23+
24+
test_add2virtualenv () {
25+
mkvirtualenv "pathtest"
26+
add2virtualenv "/full/path"
27+
cdsitepackages
28+
path_file="./virtualenv_path_extensions.pth"
29+
assertTrue "No /full/path in `cat $path_file`" "grep /full/path $path_file"
30+
cd -
31+
}
32+
33+
test_add2virtualenv_relative () {
34+
mkvirtualenv "pathtest"
35+
parent_dir=$(dirname $(pwd))
36+
base_dir=$(basename $(pwd))
37+
add2virtualenv "../$base_dir"
38+
cdsitepackages
39+
path_file="./virtualenv_path_extensions.pth"
40+
assertTrue "No $parent_dir/$base_dir in \"`cat $path_file`\"" "grep \"$parent_dir/$base_dir\" $path_file"
41+
cd - >/dev/null 2>&1
42+
}
43+
44+
45+
. "$test_dir/shunit2"

tests/test_cd.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/sh
2+
3+
#set -x
4+
5+
test_dir=$(dirname $0)
6+
source "$test_dir/../virtualenvwrapper_bashrc"
7+
8+
export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME"
9+
10+
oneTimeSetUp() {
11+
rm -rf "$WORKON_HOME"
12+
mkdir -p "$WORKON_HOME"
13+
}
14+
15+
oneTimeTearDown() {
16+
rm -rf "$WORKON_HOME"
17+
}
18+
19+
setUp () {
20+
echo
21+
rm -f "$test_dir/catch_output"
22+
}
23+
24+
test_cdvirtual() {
25+
pushd "$(pwd)" >/dev/null
26+
cdvirtualenv
27+
assertSame "$VIRTUAL_ENV" "$(pwd)"
28+
cdvirtualenv bin
29+
assertSame "$VIRTUAL_ENV/bin" "$(pwd)"
30+
popd >/dev/null
31+
}
32+
33+
test_cdsitepackages () {
34+
pushd "$(pwd)" >/dev/null
35+
cdsitepackages
36+
pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.)
37+
sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages"
38+
assertSame "$sitepackages" "$(pwd)"
39+
popd >/dev/null
40+
}
41+
42+
test_cdsitepackages_with_arg () {
43+
pushd "$(pwd)" >/dev/null
44+
pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.)
45+
sitepackage_subdir="$VIRTUAL_ENV/lib/python${pyvers}/site-packages/subdir"
46+
mkdir -p "${sitepackage_subdir}"
47+
cdsitepackages subdir
48+
assertSame "$sitepackage_subdir" "$(pwd)"
49+
popd >/dev/null
50+
}
51+
52+
53+
. "$test_dir/shunit2"

0 commit comments

Comments
 (0)