@@ -40,6 +40,24 @@ test_virtualenvwrapper_initialize() {
40
40
done
41
41
}
42
42
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
+
43
61
test_get_python_version () {
44
62
expected=$( python -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d.)
45
63
actual=$( virtualenvwrapper_get_python_version)
@@ -125,15 +143,32 @@ test_workon () {
125
143
assertSame " env1" $( basename " $VIRTUAL_ENV " )
126
144
}
127
145
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
+
131
157
workon env1
132
158
133
159
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 "
135
166
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
137
172
}
138
173
139
174
test_deactivate () {
@@ -147,11 +182,11 @@ test_deactivate () {
147
182
test_deactivate_hooks () {
148
183
workon env1
149
184
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
155
190
156
191
deactivate
157
192
@@ -162,10 +197,11 @@ ENV postdeactivate
162
197
GLOBAL postdeactivate"
163
198
assertSame " $expected " " $output "
164
199
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
169
205
}
170
206
171
207
test_virtualenvwrapper_show_workon_options () {
0 commit comments