File tree Expand file tree Collapse file tree 7 files changed +31
-12
lines changed
Expand file tree Collapse file tree 7 files changed +31
-12
lines changed Original file line number Diff line number Diff line change @@ -56,9 +56,19 @@ test_virtualenvwrapper_verify_workon_home() {
5656test_virtualenvwrapper_verify_workon_home_missing_dir () {
5757 old_home=" $WORKON_HOME "
5858 WORKON_HOME=" $WORKON_HOME /not_there"
59- output=$( virtualenvwrapper_verify_workon_home 2>&1 )
59+ assertTrue " Directory already exists" " [ ! -d \" $WORKON_HOME \" ]"
60+ virtualenvwrapper_verify_workon_home > " $old_home /output" 2>&1
61+ output=$( cat " $old_home /output" )
6062 assertSame " NOTE: Virtual environments directory $WORKON_HOME does not exist. Creating..." " $output "
61- assertTrue " WORKON_HOME verified unexpectedly" virtualenvwrapper_verify_workon_home
63+ WORKON_HOME=" $old_home "
64+ }
65+
66+ test_virtualenvwrapper_verify_workon_home_missing_dir_quiet () {
67+ old_home=" $WORKON_HOME "
68+ WORKON_HOME=" $WORKON_HOME /not_there_quiet"
69+ assertTrue " Directory already exists" " [ ! -d \" $WORKON_HOME \" ]"
70+ output=$( virtualenvwrapper_verify_workon_home -q 2>&1 )
71+ assertSame " " " $output "
6272 WORKON_HOME=" $old_home "
6373}
6474
Original file line number Diff line number Diff line change @@ -60,7 +60,8 @@ test_cdsitepackages_with_arg () {
6060test_cdvirtualenv_no_workon_home () {
6161 old_home=" $WORKON_HOME "
6262 export WORKON_HOME=" $WORKON_HOME /not_there"
63- output=$( cdvirtualenv 2>&1 )
63+ cdvirtualenv > " $old_home /output" 2>&1
64+ output=$( cat " $old_home /output" )
6465 assertTrue " Did not see expected message" " echo $output | grep 'does not exist'"
6566 WORKON_HOME=" $old_home "
6667}
Original file line number Diff line number Diff line change @@ -53,7 +53,8 @@ test_lssitepackages_add2virtualenv () {
5353test_no_workon_home () {
5454 old_home=" $WORKON_HOME "
5555 export WORKON_HOME=" $WORKON_HOME /not_there"
56- output=` lssitepackages should_not_be_created 2>&1 `
56+ lssitepackages > " $old_home /output" 2>&1
57+ output=$( cat " $old_home /output" )
5758 assertTrue " Did not see expected message" " echo $output | grep 'does not exist'"
5859 WORKON_HOME=" $old_home "
5960}
Original file line number Diff line number Diff line change @@ -79,8 +79,10 @@ test_no_args () {
7979test_no_workon_home () {
8080 old_home=" $WORKON_HOME "
8181 export WORKON_HOME=" $WORKON_HOME /not_there"
82- output=` mkvirtualenv should_not_be_created 2>&1 `
82+ mkvirtualenv should_be_created > " $old_home /output" 2>&1
83+ output=$( cat " $old_home /output" )
8384 assertTrue " Did not see expected message" " echo $output | grep 'does not exist'"
85+ assertTrue " Did not create environment" " [ -d \" $WORKON_HOME /should_be_created\" ]"
8486 WORKON_HOME=" $old_home "
8587}
8688
Original file line number Diff line number Diff line change @@ -33,9 +33,7 @@ test_rm_aliased () {
3333 mkvirtualenv " deleteme"
3434 deactivate
3535 alias rm=' rm -i'
36- set -x
3736 rmvirtualenv " deleteme"
38- set +x
3937 unalias rm
4038}
4139
@@ -47,7 +45,8 @@ test_no_such_env () {
4745test_no_workon_home () {
4846 old_home=" $WORKON_HOME "
4947 export WORKON_HOME=" $WORKON_HOME /not_there"
50- output=` rmvirtualenv should_not_be_created 2>&1 `
48+ rmvirtualenv should_not_be_created > " $old_home /output" 2>&1
49+ output=$( cat " $old_home /output" )
5150 assertTrue " Did not see expected message" " echo $output | grep 'does not exist'"
5251 WORKON_HOME=" $old_home "
5352}
Original file line number Diff line number Diff line change @@ -97,7 +97,8 @@ test_virtualenvwrapper_show_workon_options_no_envs () {
9797test_no_workon_home () {
9898 old_home=" $WORKON_HOME "
9999 export WORKON_HOME=" $WORKON_HOME /not_there"
100- output=` workon should_not_be_created 2>&1 `
100+ workon should_not_be_created > " $old_home /output" 2>&1
101+ output=$( cat " $old_home /output" )
101102 assertTrue " Did not see expected message" " echo $output | grep 'does not exist'"
102103 WORKON_HOME=" $old_home "
103104}
Original file line number Diff line number Diff line change @@ -95,12 +95,17 @@ virtualenvwrapper_derive_workon_home() {
9595# seperate from creating the files in it because this used to just error
9696# and maybe other things rely on the dir existing before that happens.
9797virtualenvwrapper_verify_workon_home () {
98+ RC=0
9899 if [ ! -d " $WORKON_HOME " ]
99100 then
100- [ " $1 " != " -q" ] && echo " NOTE: Virtual environments directory $WORKON_HOME does not exist. Creating..." 1>&2
101- mkdir $WORKON_HOME
101+ if [ " $1 " != " -q" ]
102+ then
103+ echo " NOTE: Virtual environments directory $WORKON_HOME does not exist. Creating..." 1>&2
104+ fi
105+ mkdir -p $WORKON_HOME
106+ RC=$?
102107 fi
103- return 0
108+ return $RC
104109}
105110
106111# HOOK_VERBOSE_OPTION="-q"
You can’t perform that action at this time.
0 commit comments