@@ -7,10 +7,12 @@ oneTimeSetUp() {
7
7
rm -rf " $WORKON_HOME "
8
8
mkdir -p " $WORKON_HOME "
9
9
source " $test_dir /../virtualenvwrapper.sh"
10
- mkvirtualenv " env1" > /dev/null 2>&1
11
- mkvirtualenv " env2" > /dev/null 2>&1
12
- mkvirtualenv " env with space" > /dev/null 2>&1
13
- deactivate > /dev/null 2>&1
10
+ mkvirtualenv " test1" > /dev/null 2>&1
11
+ mkvirtualenv " test2" > /dev/null 2>&1
12
+ # Only test with leading and internal spaces. Directory names with trailing spaces are legal,
13
+ # and work with virtualenv on OSX, but error out on Linux.
14
+ mkvirtualenv " env with space" > /dev/null 2>&1
15
+ deactivate > /dev/null 2>&1
14
16
}
15
17
16
18
oneTimeTearDown () {
@@ -27,9 +29,9 @@ tearDown () {
27
29
}
28
30
29
31
test_workon () {
30
- workon env1
32
+ workon test1
31
33
assertTrue virtualenvwrapper_verify_active_environment
32
- assertSame " env1 " $( basename " $VIRTUAL_ENV " )
34
+ assertSame " test1 " $( basename " $VIRTUAL_ENV " )
33
35
}
34
36
35
37
test_workon_activate_hooks () {
@@ -39,15 +41,15 @@ test_workon_activate_hooks () {
39
41
echo " echo GLOBAL ${t} activate >> \" $TMPDIR /catch_output\" " >> " $WORKON_HOME /${t} activate"
40
42
chmod +x " $WORKON_HOME /${t} activate"
41
43
42
- echo " #!/bin/sh" > " $WORKON_HOME /env2 /bin/${t} activate"
43
- echo " echo ENV ${t} activate >> \" $TMPDIR /catch_output\" " >> " $WORKON_HOME /env1 /bin/${t} activate"
44
- chmod +x " $WORKON_HOME /env1 /bin/${t} activate"
44
+ echo " #!/bin/sh" > " $WORKON_HOME /test2 /bin/${t} activate"
45
+ echo " echo ENV ${t} activate >> \" $TMPDIR /catch_output\" " >> " $WORKON_HOME /test1 /bin/${t} activate"
46
+ chmod +x " $WORKON_HOME /test1 /bin/${t} activate"
45
47
done
46
48
47
49
rm -f " $TMPDIR /catch_output"
48
50
touch " $TMPDIR /catch_output"
49
51
50
- workon env1
52
+ workon test1
51
53
52
54
output=$( cat " $TMPDIR /catch_output" )
53
55
expected=" GLOBAL preactivate
@@ -59,27 +61,29 @@ ENV postactivate"
59
61
60
62
for t in pre post
61
63
do
62
- rm -f " $WORKON_HOME /env1 /bin/${t} activate"
64
+ rm -f " $WORKON_HOME /test1 /bin/${t} activate"
63
65
rm -f " $WORKON_HOME /${t} activate"
64
66
done
65
67
}
66
68
67
69
test_virtualenvwrapper_show_workon_options () {
68
70
mkdir " $WORKON_HOME /not_env"
69
- (cd " $WORKON_HOME " ; ln -s env1 link_env)
71
+ (cd " $WORKON_HOME " ; ln -s test1 link_env)
70
72
envs=$( virtualenvwrapper_show_workon_options | tr ' \n' ' ' )
71
- assertSame " env with space env1 env2 link_env " " $envs "
73
+ # On OSX there are two trailing spaces, on Linux one, so compare substring
74
+ assertSame " env with space link_env test1 test2 " " ${envs: 0: 37} "
72
75
rmdir " $WORKON_HOME /not_env"
73
76
rm -f " $WORKON_HOME /link_env"
74
77
}
75
78
76
79
test_virtualenvwrapper_show_workon_options_grep_options () {
77
80
mkdir " $WORKON_HOME /not_env"
78
- (cd " $WORKON_HOME " ; ln -s env1 link_env)
81
+ (cd " $WORKON_HOME " ; ln -s test1 link_env)
79
82
export GREP_OPTIONS=" --count"
80
83
envs=$( virtualenvwrapper_show_workon_options | tr ' \n' ' ' )
81
84
unset GREP_OPTIONS
82
- assertSame " env with space env1 env2 link_env " " $envs "
85
+ # On OSX there are two trailing spaces, on Linux one, so compare substring
86
+ assertSame " env with space link_env test1 test2 " " ${envs: 0: 37} "
83
87
rmdir " $WORKON_HOME /not_env"
84
88
rm -f " $WORKON_HOME /link_env"
85
89
}
@@ -95,15 +99,17 @@ test_virtualenvwrapper_show_workon_options_chpwd () {
95
99
}
96
100
mkdir " $WORKON_HOME /not_env"
97
101
envs=$( virtualenvwrapper_show_workon_options | tr ' \n' ' ' )
98
- assertSame " env with space env1 env2 " " $envs "
102
+ # On OSX there are two trailing spaces, on Linux one, so compare substring
103
+ assertSame " env with space test1 test2 " " ${envs: 0: 28} "
99
104
rmdir " $WORKON_HOME /not_env"
100
105
rm -f " $WORKON_HOME /link_env"
101
106
}
102
107
103
108
test_virtualenvwrapper_show_workon_options_no_envs () {
104
109
old_home=" $WORKON_HOME "
105
110
export WORKON_HOME=${TMPDIR:-/ tmp} /$$
106
- envs=$( virtualenvwrapper_show_workon_options 2> /dev/null | tr ' \n' ' ' )
111
+ envs=$( virtualenvwrapper_show_workon_options 2> /dev/null\
112
+ | tr ' \n' ' ' 2> /dev/null | tr ' ' ' ' 2> /dev/null)
107
113
assertSame " " " $envs "
108
114
export WORKON_HOME=" $old_home "
109
115
}
@@ -118,25 +124,25 @@ test_no_workon_home () {
118
124
}
119
125
120
126
test_workon_dot () {
121
- cd $WORKON_HOME /env1
127
+ cd $WORKON_HOME /test1
122
128
workon .
123
129
assertTrue virtualenvwrapper_verify_active_environment
124
- assertSame " env1 " $( basename " $VIRTUAL_ENV " )
130
+ assertSame " test1 " $( basename " $VIRTUAL_ENV " )
125
131
}
126
132
127
133
test_workon_dot_with_space () {
128
- cd $WORKON_HOME /" env with space"
134
+ cd $WORKON_HOME /" env with space"
129
135
workon .
130
136
assertTrue virtualenvwrapper_verify_active_environment
131
137
env_name=$( basename " $VIRTUAL_ENV " )
132
- assertSame " env with space" " $env_name "
138
+ assertSame " env with space" " $env_name "
133
139
}
134
140
135
141
test_workon_with_space () {
136
- workon " env with space"
142
+ workon " env with space"
137
143
assertTrue virtualenvwrapper_verify_active_environment
138
144
env_name=$( basename " $VIRTUAL_ENV " )
139
- assertSame " env with space" " $env_name "
145
+ assertSame " env with space" " $env_name "
140
146
}
141
147
142
148
. " $test_dir /shunit2"
0 commit comments