@@ -10,22 +10,20 @@ setUp () {
1010 rm -rf " $WORKON_HOME "
1111 mkdir -p " $WORKON_HOME "
1212 source " $test_dir /../virtualenvwrapper.sh"
13- echo
1413 rm -f " $test_dir /catch_output"
14+ echo
1515}
1616
1717tearDown () {
1818 rm -rf " $WORKON_HOME "
1919}
2020
21-
2221test_cpvirtualenv () {
2322 mkvirtualenv " source"
24- (cd tests/testpackage && python setup.py install)
23+ (cd tests/testpackage && python setup.py install) > /dev/null 2>&1
2524 cpvirtualenv " source" " destination"
26- deactivate
25+ assertSame " destination " $( basename " $VIRTUAL_ENV " )
2726 rmvirtualenv " source"
28- workon " destination"
2927 testscript=" $( which testscript.py) "
3028 assertTrue " Environment test script not found in path" " [ $WORKON_HOME /destination/bin/testscript.py -ef $testscript ]"
3129 testscriptcontent=" $( cat $testscript ) "
@@ -36,7 +34,7 @@ test_cpvirtualenv () {
3634
3735test_cprelocatablevirtualenv () {
3836 mkvirtualenv " source"
39- (cd tests/testpackage && python setup.py install)
37+ (cd tests/testpackage && python setup.py install) > /dev/null 2>&1
4038 assertTrue " virtualenv --relocatable \" $WORKON_HOME /source\" "
4139 cpvirtualenv " source" " destination"
4240 testscript=" $( which testscript.py) "
@@ -50,5 +48,33 @@ test_cp_notexists () {
5048 assertSame " $out " " virtualenvthatdoesntexist virtualenv doesn't exist"
5149}
5250
51+ test_hooks () {
52+ mkvirtualenv " source"
53+
54+ export pre_test_dir=$( cd " $test_dir " ; pwd)
55+ echo " echo GLOBAL premkvirtualenv \` pwd\` \"\$ @\" >> \" $pre_test_dir /catch_output\" " >> " $WORKON_HOME /premkvirtualenv"
56+ chmod +x " $WORKON_HOME /premkvirtualenv"
57+ echo " echo GLOBAL postmkvirtualenv >> $test_dir /catch_output" > " $WORKON_HOME /postmkvirtualenv"
58+ echo " #!/bin/sh" > " $WORKON_HOME /precpvirtualenv"
59+ echo " echo GLOBAL precpvirtualenv \` pwd\` \"\$ @\" >> \" $pre_test_dir /catch_output\" " >> " $WORKON_HOME /precpvirtualenv"
60+ chmod +x " $WORKON_HOME /precpvirtualenv"
61+ echo " #!/bin/sh" > " $WORKON_HOME /postcpvirtualenv"
62+ echo " echo GLOBAL postcpvirtualenv >> $test_dir /catch_output" > " $WORKON_HOME /postcpvirtualenv"
63+
64+ cpvirtualenv " source" " destination"
65+
66+ output=$( cat " $test_dir /catch_output" )
67+
68+ expected=" GLOBAL precpvirtualenv $WORKON_HOME source destination
69+ GLOBAL premkvirtualenv $WORKON_HOME destination
70+ GLOBAL postmkvirtualenv
71+ GLOBAL postcpvirtualenv"
72+
73+ assertSame " $expected " " $output "
74+ rm -f " $WORKON_HOME /premkvirtualenv"
75+ rm -f " $WORKON_HOME /postmkvirtualenv"
76+ deactivate
77+ }
78+
5379. " $test_dir /shunit2"
5480
0 commit comments