@@ -40,6 +40,24 @@ test_virtualenvwrapper_initialize() {
4040 done
4141}
4242
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+
4361test_get_python_version () {
4462 expected=$( python -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d.)
4563 actual=$( virtualenvwrapper_get_python_version)
@@ -125,15 +143,32 @@ test_workon () {
125143 assertSame " env1" $( basename " $VIRTUAL_ENV " )
126144}
127145
128- test_postactivate_hook () {
129- echo " echo ENV postactivate > $test_dir /catch_output" > " $WORKON_HOME /env1/bin/postactivate"
130-
146+ test_workon_activate_hooks () {
147+ for t in pre post
148+ do
149+ echo " echo GLOBAL ${t} activate >> \" $test_dir /catch_output\" " >> " $WORKON_HOME /${t} activate"
150+ chmod +x " $WORKON_HOME /${t} activate"
151+ echo " echo ENV ${t} activate >> \" $test_dir /catch_output\" " >> " $WORKON_HOME /env1/bin/${t} activate"
152+ chmod +x " $WORKON_HOME /env1/bin/${t} activate"
153+ done
154+
155+ rm " $test_dir /catch_output"
156+
131157 workon env1
132158
133159 output=$( cat " $test_dir /catch_output" )
134- assertSame " ENV postactivate" " $output "
160+ expected=" GLOBAL preactivate
161+ ENV preactivate
162+ GLOBAL postactivate
163+ ENV postactivate"
164+
165+ assertSame " $expected " " $output "
135166
136- rm -f " $WORKON_HOME /env1/bin/postactivate"
167+ for t in pre post
168+ do
169+ rm -f " $WORKON_HOME /env1/bin/${t} activate"
170+ rm -f " $WORKON_HOME /${t} activate"
171+ done
137172}
138173
139174test_deactivate () {
@@ -147,11 +182,11 @@ test_deactivate () {
147182test_deactivate_hooks () {
148183 workon env1
149184
150- echo " echo GLOBAL predeactivate >> $test_dir /catch_output " > " $WORKON_HOME /predeactivate "
151- echo " echo GLOBAL postdeactivate >> $test_dir /catch_output " > " $WORKON_HOME /postdeactivate "
152-
153- echo " echo ENV predeactivate >> $test_dir /catch_output" > " $WORKON_HOME /env1/bin/predeactivate "
154- echo " echo ENV postdeactivate >> $test_dir /catch_output " > " $WORKON_HOME /env1/bin/postdeactivate "
185+ for t in pre post
186+ do
187+ echo " echo GLOBAL ${t} deactivate >> $test_dir /catch_output " > " $WORKON_HOME / ${t} deactivate "
188+ echo " echo ENV ${t} deactivate >> $test_dir /catch_output" > " $WORKON_HOME /env1/bin/${t} deactivate "
189+ done
155190
156191 deactivate
157192
@@ -162,10 +197,11 @@ ENV postdeactivate
162197GLOBAL postdeactivate"
163198 assertSame " $expected " " $output "
164199
165- rm -f " $WORKON_HOME /env1/bin/predeactivate"
166- rm -f " $WORKON_HOME /env1/bin/postdeactivate"
167- rm -f " $WORKON_HOME /predeactivate"
168- rm -f " $WORKON_HOME /postdeactivate"
200+ for t in pre post
201+ do
202+ rm -f " $WORKON_HOME /env1/bin/${t} activate"
203+ rm -f " $WORKON_HOME /${t} activate"
204+ done
169205}
170206
171207test_virtualenvwrapper_show_workon_options () {
0 commit comments