Skip to content

Commit 6443c18

Browse files
committed
Made cd command work with space in virtualenv name
1 parent 0225913 commit 6443c18

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

tests/test_cd.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ oneTimeSetUp() {
99
unset VIRTUAL_ENV
1010
source "$test_dir/../virtualenvwrapper.sh"
1111
mkvirtualenv cd-test >/dev/null 2>&1
12+
mkvirtualenv "env with space" >/dev/null 2>&1
1213
deactivate
1314
}
1415

@@ -38,6 +39,16 @@ test_cdvirtual() {
3839
virtualenvwrapper_cd "$start_dir"
3940
}
4041

42+
test_cdvirtual_space_in_name() {
43+
workon "env with space"
44+
start_dir="$(pwd)"
45+
cdvirtualenv
46+
assertSame "$VIRTUAL_ENV" "$(pwd)"
47+
cdvirtualenv bin
48+
assertSame "$VIRTUAL_ENV/bin" "$(pwd)"
49+
virtualenvwrapper_cd "$start_dir"
50+
}
51+
4152
test_cdsitepackages () {
4253
start_dir="$(pwd)"
4354
cdsitepackages
@@ -47,6 +58,16 @@ test_cdsitepackages () {
4758
virtualenvwrapper_cd "$start_dir"
4859
}
4960

61+
test_cdsitepackages_space_in_name () {
62+
workon "env with space"
63+
start_dir="$(pwd)"
64+
cdsitepackages
65+
pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.)
66+
sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages"
67+
assertSame "$sitepackages" "$(pwd)"
68+
virtualenvwrapper_cd "$start_dir"
69+
}
70+
5071
test_cdsitepackages_with_arg () {
5172
start_dir="$(pwd)"
5273
pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.)

virtualenvwrapper.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ function cdsitepackages {
892892
function cdvirtualenv {
893893
virtualenvwrapper_verify_workon_home || return 1
894894
virtualenvwrapper_verify_active_environment || return 1
895-
virtualenvwrapper_cd $VIRTUAL_ENV/$1
895+
virtualenvwrapper_cd "$VIRTUAL_ENV"/$1
896896
}
897897

898898
# Shows the content of the site-packages directory of the currently-active

0 commit comments

Comments
 (0)