@@ -20,10 +20,10 @@ tearDown() {
20
20
}
21
21
22
22
test_new_env_activated () {
23
- mkvirtualenv " source"
23
+ mkvirtualenv " source" > /dev/null 2>&1
24
24
(cd tests/testpackage && python setup.py install) > /dev/null 2>&1
25
- cpvirtualenv " source" " destination"
26
- rmvirtualenv " source"
25
+ cpvirtualenv " source" " destination" > /dev/null 2>&1
26
+ rmvirtualenv " source" > /dev/null 2>&1
27
27
testscript=" $( which testscript.py) "
28
28
assertTrue " Environment test script not found in path" " [ $WORKON_HOME /destination/bin/testscript.py -ef $testscript ]"
29
29
testscriptcontent=" $( cat $testscript ) "
@@ -32,44 +32,78 @@ test_new_env_activated () {
32
32
}
33
33
34
34
test_virtual_env_variable () {
35
- mkvirtualenv " source"
36
- cpvirtualenv " source" " destination"
35
+ mkvirtualenv " source" > /dev/null 2>&1
36
+ cpvirtualenv " source" " destination" > /dev/null 2>&1
37
37
assertSame " Wrong virtualenv name" " destination" $( basename " $VIRTUAL_ENV " )
38
38
assertTrue " $WORKON_HOME not in $VIRTUAL_ENV " " echo $VIRTUAL_ENV | grep -q $WORKON_HOME "
39
39
}
40
40
41
- fake_virtualenv () {
41
+ fake_venv () {
42
+ # ##
43
+ # create a silly file to ensure copy happens
44
+ # ##
42
45
typeset envname=" $1 "
43
- touch " $envname /fake_virtualenv_was_here"
44
46
virtualenv $@
47
+ touch " $WORKON_HOME /$envname /fake_virtualenv_was_here"
48
+ }
49
+
50
+ fake_venv_clone () {
51
+ # ##
52
+ # create a silly file to ensure copy happens
53
+ # ##
54
+ typeset src_path=" $1 "
55
+ touch " $src_path /fake_virtualenv_clone_was_here"
56
+ virtualenv-clone $@
45
57
}
46
58
47
59
test_virtualenvwrapper_virtualenv_variable () {
48
- mkvirtualenv " source"
49
- export VIRTUALENVWRAPPER_VIRTUALENV=fake_virtualenv
50
- cpvirtualenv " source" " destination"
60
+
61
+ eval ' virtualenvwrapper_verify_virtualenv () {
62
+ return 0
63
+ }'
64
+
65
+ VIRTUALENVWRAPPER_VIRTUALENV=fake_venv
66
+ assertSame " VIRTUALENVWRAPPER_VIRTUALENV is not set correctly" " $VIRTUALENVWRAPPER_VIRTUALENV " " fake_venv"
67
+
68
+ mkvirtualenv " source" > /dev/null 2>&1
69
+ assertTrue " Fake file not made in fake_venv" " [ -f " $VIRTUAL_ENV /fake_virtualenv_was_here" ]"
70
+ cpvirtualenv " source" " destination" > /dev/null 2>&1
51
71
unset VIRTUALENVWRAPPER_VIRTUALENV
52
- assertTrue " wrapper was not run" " [ -f $VIRTUAL_ENV /fake_virtualenv_was_here ]"
72
+ assertTrue " VIRTUALENVWRAPPER_CLONE did not clone fake file" " [ -f $WORKON_HOME /destination/fake_virtualenv_was_here ]"
73
+ }
74
+
75
+ test_virtualenvwrapper_virtualenv_clone_variable () {
76
+
77
+ eval ' virtualenvwrapper_verify_virtualenv_clone () {
78
+ return 0
79
+ }'
80
+
81
+ VIRTUALENVWRAPPER_VIRTUALENV_CLONE=fake_venv_clone
82
+ assertSame " VIRTUALENVWRAPPER_VIRTUALENV_CLONE is not set correctly" " $VIRTUALENVWRAPPER_VIRTUALENV_CLONE " " fake_venv_clone"
83
+
84
+ mkvirtualenv " source" > /dev/null 2>&1
85
+ cpvirtualenv " source" " destination" > /dev/null 2>&1
86
+ unset VIRTUALENVWRAPPER_VIRTUALENV_CLONE
87
+ assertTrue " VIRTUALENVWRAPPER_CLONE did not clone fake file" " [ -f $WORKON_HOME /destination/fake_virtualenv_clone_was_here ]"
53
88
}
54
89
55
90
test_source_relocatable () {
56
- mkvirtualenv " source"
91
+ mkvirtualenv " source" > /dev/null 2>&1
57
92
(cd tests/testpackage && python setup.py install) > /dev/null 2>&1
58
93
assertTrue " virtualenv --relocatable \" $WORKON_HOME /source\" "
59
- cpvirtualenv " source" " destination"
94
+ cpvirtualenv " source" " destination" > /dev/null 2>&1
60
95
testscript=" $( which testscript.py) "
61
96
assertTrue " Environment test script not the same as copy" " [ $WORKON_HOME /destination/bin/testscript.py -ef $testscript ]"
62
97
assertTrue virtualenvwrapper_verify_active_environment
63
98
assertSame " Wrong virtualenv name" " destination" $( basename " $VIRTUAL_ENV " )
64
99
}
65
100
66
101
test_source_does_not_exist () {
67
- out=" $( cpvirtualenv virtualenvthatdoesntexist foo) "
68
- assertSame " $out " " virtualenvthatdoesntexist virtualenv doesn't exist"
102
+ assertSame " Please provide a valid virtualenv to copy." " $( cpvirtualenv virtualenvthatdoesntexist foo) "
69
103
}
70
104
71
105
test_hooks () {
72
- mkvirtualenv " source"
106
+ mkvirtualenv " source" > /dev/null 2>&1
73
107
74
108
export pre_test_dir=$( cd " $test_dir " ; pwd)
75
109
@@ -89,12 +123,12 @@ test_hooks () {
89
123
echo " #!/bin/sh" > " $WORKON_HOME /postcpvirtualenv"
90
124
echo " echo GLOBAL postcpvirtualenv >> $test_dir /catch_output" > " $WORKON_HOME /postcpvirtualenv"
91
125
92
- cpvirtualenv " source" " destination"
126
+ cpvirtualenv " source" " destination" > /dev/null 2>&1
93
127
94
128
output=$( cat " $test_dir /catch_output" )
95
129
workon_home_as_pwd=$( cd $WORKON_HOME ; pwd)
96
130
97
- expected=" GLOBAL precpvirtualenv $workon_home_as_pwd source destination
131
+ expected=" GLOBAL precpvirtualenv $workon_home_as_pwd $workon_home_as_pwd / source destination
98
132
GLOBAL premkvirtualenv $workon_home_as_pwd destination
99
133
GLOBAL postmkvirtualenv
100
134
GLOBAL postcpvirtualenv"
@@ -108,7 +142,7 @@ GLOBAL postcpvirtualenv"
108
142
test_no_site_packages () {
109
143
# See issue #102
110
144
mkvirtualenv " source" --no-site-packages > /dev/null 2>&1
111
- cpvirtualenv " source" " destination"
145
+ cpvirtualenv " source" " destination" > /dev/null 2>&1
112
146
ngsp_file=" ` virtualenvwrapper_get_site_packages_dir` /../no-global-site-packages.txt"
113
147
assertTrue " $ngsp_file does not exist in copied env" " [ -f \" $ngsp_file \" ]"
114
148
}
@@ -118,7 +152,7 @@ test_no_site_packages_default_args () {
118
152
VIRTUALENVWRAPPER_VIRTUALENV_ARGS=" --no-site-packages"
119
153
# With the argument, verify that they are not copied.
120
154
mkvirtualenv " source" > /dev/null 2>&1
121
- cpvirtualenv " source" " destination"
155
+ cpvirtualenv " source" " destination" > /dev/null 2>&1
122
156
ngsp_file=" ` virtualenvwrapper_get_site_packages_dir` /../no-global-site-packages.txt"
123
157
assertTrue " $ngsp_file does not exist" " [ -f \" $ngsp_file \" ]"
124
158
unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS
@@ -128,7 +162,7 @@ test_no_site_packages_default_behavior () {
128
162
# See issue #102
129
163
# virtualenv 1.7 changed to make --no-site-packages the default
130
164
mkvirtualenv " source" > /dev/null 2>&1
131
- cpvirtualenv " source" " destination"
165
+ cpvirtualenv " source" " destination" > /dev/null 2>&1
132
166
ngsp_file=" ` virtualenvwrapper_get_site_packages_dir` /../no-global-site-packages.txt"
133
167
assertTrue " $ngsp_file does not exist in copied env" " [ -f \" $ngsp_file \" ]"
134
168
}
0 commit comments