@@ -20,10 +20,10 @@ tearDown() {
2020}
2121
2222test_new_env_activated () {
23- mkvirtualenv " source"
23+ mkvirtualenv " source" > /dev/null 2>&1
2424 (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
2727 testscript=" $( which testscript.py) "
2828 assertTrue " Environment test script not found in path" " [ $WORKON_HOME /destination/bin/testscript.py -ef $testscript ]"
2929 testscriptcontent=" $( cat $testscript ) "
@@ -32,44 +32,78 @@ test_new_env_activated () {
3232}
3333
3434test_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
3737 assertSame " Wrong virtualenv name" " destination" $( basename " $VIRTUAL_ENV " )
3838 assertTrue " $WORKON_HOME not in $VIRTUAL_ENV " " echo $VIRTUAL_ENV | grep -q $WORKON_HOME "
3939}
4040
41- fake_virtualenv () {
41+ fake_venv () {
42+ # ##
43+ # create a silly file to ensure copy happens
44+ # ##
4245 typeset envname=" $1 "
43- touch " $envname /fake_virtualenv_was_here"
4446 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 $@
4557}
4658
4759test_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
5171 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 ]"
5388}
5489
5590test_source_relocatable () {
56- mkvirtualenv " source"
91+ mkvirtualenv " source" > /dev/null 2>&1
5792 (cd tests/testpackage && python setup.py install) > /dev/null 2>&1
5893 assertTrue " virtualenv --relocatable \" $WORKON_HOME /source\" "
59- cpvirtualenv " source" " destination"
94+ cpvirtualenv " source" " destination" > /dev/null 2>&1
6095 testscript=" $( which testscript.py) "
6196 assertTrue " Environment test script not the same as copy" " [ $WORKON_HOME /destination/bin/testscript.py -ef $testscript ]"
6297 assertTrue virtualenvwrapper_verify_active_environment
6398 assertSame " Wrong virtualenv name" " destination" $( basename " $VIRTUAL_ENV " )
6499}
65100
66101test_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) "
69103}
70104
71105test_hooks () {
72- mkvirtualenv " source"
106+ mkvirtualenv " source" > /dev/null 2>&1
73107
74108 export pre_test_dir=$( cd " $test_dir " ; pwd)
75109
@@ -89,12 +123,12 @@ test_hooks () {
89123 echo " #!/bin/sh" > " $WORKON_HOME /postcpvirtualenv"
90124 echo " echo GLOBAL postcpvirtualenv >> $test_dir /catch_output" > " $WORKON_HOME /postcpvirtualenv"
91125
92- cpvirtualenv " source" " destination"
126+ cpvirtualenv " source" " destination" > /dev/null 2>&1
93127
94128 output=$( cat " $test_dir /catch_output" )
95129 workon_home_as_pwd=$( cd $WORKON_HOME ; pwd)
96130
97- expected=" GLOBAL precpvirtualenv $workon_home_as_pwd source destination
131+ expected=" GLOBAL precpvirtualenv $workon_home_as_pwd $workon_home_as_pwd / source destination
98132GLOBAL premkvirtualenv $workon_home_as_pwd destination
99133GLOBAL postmkvirtualenv
100134GLOBAL postcpvirtualenv"
@@ -108,7 +142,7 @@ GLOBAL postcpvirtualenv"
108142test_no_site_packages () {
109143 # See issue #102
110144 mkvirtualenv " source" --no-site-packages > /dev/null 2>&1
111- cpvirtualenv " source" " destination"
145+ cpvirtualenv " source" " destination" > /dev/null 2>&1
112146 ngsp_file=" ` virtualenvwrapper_get_site_packages_dir` /../no-global-site-packages.txt"
113147 assertTrue " $ngsp_file does not exist in copied env" " [ -f \" $ngsp_file \" ]"
114148}
@@ -118,7 +152,7 @@ test_no_site_packages_default_args () {
118152 VIRTUALENVWRAPPER_VIRTUALENV_ARGS=" --no-site-packages"
119153 # With the argument, verify that they are not copied.
120154 mkvirtualenv " source" > /dev/null 2>&1
121- cpvirtualenv " source" " destination"
155+ cpvirtualenv " source" " destination" > /dev/null 2>&1
122156 ngsp_file=" ` virtualenvwrapper_get_site_packages_dir` /../no-global-site-packages.txt"
123157 assertTrue " $ngsp_file does not exist" " [ -f \" $ngsp_file \" ]"
124158 unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS
@@ -128,7 +162,7 @@ test_no_site_packages_default_behavior () {
128162 # See issue #102
129163 # virtualenv 1.7 changed to make --no-site-packages the default
130164 mkvirtualenv " source" > /dev/null 2>&1
131- cpvirtualenv " source" " destination"
165+ cpvirtualenv " source" " destination" > /dev/null 2>&1
132166 ngsp_file=" ` virtualenvwrapper_get_site_packages_dir` /../no-global-site-packages.txt"
133167 assertTrue " $ngsp_file does not exist in copied env" " [ -f \" $ngsp_file \" ]"
134168}
0 commit comments