Diff
1diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
2index 5761ccdd381249ef8fcb0099f28abd7c9264bf19..d91669ac9eb57b64ad974eea2a29b1bf18fb3136 100644
3--- a/autoswitch_virtualenv.plugin.zsh
4+++ b/autoswitch_virtualenv.plugin.zsh
5@@ -64,7 +64,11 @@ function _maybeworkon() {
6 local venv_type="$2"
7 local venv_name="$(_get_venv_name $venv_dir $venv_type)"
8
9- local DEFAULT_MESSAGE_FORMAT="Switching %venv_type: ${BOLD}${PURPLE}%venv_name${NORMAL} ${GREEN}[%py_version]${NORMAL}"
10+ local DEFAULT_MESSAGE_FORMAT="Switching %venv_type: ${BOLD}${PURPLE}%venv_name${NORMAL} ${GREEN}[๐%py_version]${NORMAL}"
11+ if [[ "$LANG" != *".UTF-8" ]]; then
12+ # Remove multibyte characters if the terminal does not support utf-8
13+ DEFAULT_MESSAGE_FORMAT="${DEFAULT_MESSAGE_FORMAT/๐/}"
14+ fi
15
16 if [[ -z "$VIRTUAL_ENV" || "$venv_name" != "$(basename $VIRTUAL_ENV)" ]]; then
17
18diff --git a/tests/test_check_venv.zunit b/tests/test_check_venv.zunit
19index 0549a693356e576dfb0ae618593f1b604ef28196..058c815dddcf982768a170e03bc4b1cb2628f082 100644
20--- a/tests/test_check_venv.zunit
21+++ b/tests/test_check_venv.zunit
22@@ -18,6 +18,8 @@
23 load "../autoswitch_virtualenv.plugin.zsh"
24 TARGET="$(mktemp -d)"
25 OLDPWD="$(mktemp -d)"
26+
27+ LANG=".UTF-8"
28 }
29
30
31@@ -111,7 +113,7 @@
32 run check_venv
33
34 assert $status equals 0
35- assert "$output" same_as "Switching virtualenv: \e[1m\e[35mfoobar\e[0m \e[32m[$PYTHON_VERSION]\e[0m"
36+ assert "$output" same_as "Switching virtualenv: \e[1m\e[35mfoobar\e[0m \e[32m[๐$PYTHON_VERSION]\e[0m"
37 }
38
39 @test 'check_venv - No security warning for readable by group permission' {
40@@ -125,7 +127,7 @@
41 run check_venv
42
43 assert $status equals 0
44- assert "$output" same_as "Switching virtualenv: \e[1m\e[35mfoobar\e[0m \e[32m[$PYTHON_VERSION]\e[0m"
45+ assert "$output" same_as "Switching virtualenv: \e[1m\e[35mfoobar\e[0m \e[32m[๐$PYTHON_VERSION]\e[0m"
46 }
47
48 @test 'check_venv - No security warning for readable only by owner permission' {
49@@ -138,7 +140,7 @@
50 run check_venv
51
52 assert $status equals 0
53- assert "$output" same_as "Switching virtualenv: \e[1m\e[35mfoobar\e[0m \e[32m[$PYTHON_VERSION]\e[0m"
54+ assert "$output" same_as "Switching virtualenv: \e[1m\e[35mfoobar\e[0m \e[32m[๐$PYTHON_VERSION]\e[0m"
55 }
56
57
58@@ -149,7 +151,7 @@
59 run check_venv
60
61 assert $status equals 0
62- assert "$output" same_as "Switching virtualenv: \e[1m\e[35mfoodefault\e[0m \e[32m[$PYTHON_VERSION]\e[0m"
63+ assert "$output" same_as "Switching virtualenv: \e[1m\e[35mfoodefault\e[0m \e[32m[๐$PYTHON_VERSION]\e[0m"
64 }
65
66
67@@ -165,7 +167,7 @@
68 run check_venv
69
70 assert $status equals 0
71- assert "$output" same_as "Switching pipenv: \e[1m\e[35mfoobar\e[0m \e[32m[$PYTHON_VERSION]\e[0m"
72+ assert "$output" same_as "Switching pipenv: \e[1m\e[35mfoobar\e[0m \e[32m[๐$PYTHON_VERSION]\e[0m"
73 }
74
75
76@@ -206,5 +208,5 @@
77 run check_venv
78
79 assert $status equals 0
80- assert "$output" same_as "Switching virtualenv: \e[1m\e[35mfoobar\e[0m \e[32m[$PYTHON_VERSION]\e[0m"
81+ assert "$output" same_as "Switching virtualenv: \e[1m\e[35mfoobar\e[0m \e[32m[๐$PYTHON_VERSION]\e[0m"
82 }
83diff --git a/tests/test_install_requirements.zunit b/tests/test_install_requirements.zunit
84index 1af1a0af4109ffd0436185c3ca22b0be569f16ad..6e098f3dc19a0b81d4492fc0c55c5d5834d4165c 100644
85--- a/tests/test_install_requirements.zunit
86+++ b/tests/test_install_requirements.zunit
87@@ -4,7 +4,8 @@
88 export DISABLE_AUTOSWITCH_VENV="1"
89 load "../autoswitch_virtualenv.plugin.zsh"
90 unset AUTOSWITCH_DEFAULT_REQUIREMENTS
91-
92+ unset AUTOSWITCH_PIPINSTALL
93+
94 function read {
95 eval $1=\"y\"
96 echo y
97diff --git a/tests/test_maybeworkon.zunit b/tests/test_maybeworkon.zunit
98index ae6e22e99526c547e5537d02aeca63398fb0b22a..d5fe6591f2bd9f558cb88a849e665e88ea260ccd 100644
99--- a/tests/test_maybeworkon.zunit
100+++ b/tests/test_maybeworkon.zunit
101@@ -15,6 +15,8 @@
102 export DISABLE_AUTOSWITCH_VENV="1"
103 load "../autoswitch_virtualenv.plugin.zsh"
104 TARGET="$(mktemp -d)"
105+
106+ LANG=".UTF-8"
107 }
108
109 @teardown {
110@@ -38,7 +40,7 @@
111 run _maybeworkon "$TEST_VIRTUALENV" virtualenv
112
113 assert $state equals 0
114- assert "$output" same_as "Switching virtualenv: \e[1m\e[35mfoobar\e[0m \e[32m[$PYTHON_VERSION]\e[0m"
115+ assert "$output" same_as "Switching virtualenv: \e[1m\e[35mfoobar\e[0m \e[32m[๐$PYTHON_VERSION]\e[0m"
116 }
117
118 @test '_maybeworkon - custom message' {
119@@ -67,7 +69,7 @@
120 run _maybeworkon "$TEST_VIRTUALENV" virtualfoo
121
122 assert $state equals 0
123- assert "$output" contains "Switching virtualfoo: \e[1m\e[35mfoobar\e[0m \e[32m[$PYTHON_VERSION]\e[0m"
124+ assert "$output" contains "Switching virtualfoo: \e[1m\e[35mfoobar\e[0m \e[32m[๐$PYTHON_VERSION]\e[0m"
125 }
126
127 @test '_maybeworkon - switches virtualenv if current virtualenv is different (silent)' {
128@@ -93,5 +95,5 @@
129 run _maybeworkon hello-world-foo-de31f pipenv
130
131 assert $state equals 0
132- assert "$output" same_as "Switching pipenv: \e[1m\e[35mhello-world-foo\e[0m \e[32m[$PYTHON_VERSION]\e[0m"
133+ assert "$output" same_as "Switching pipenv: \e[1m\e[35mhello-world-foo\e[0m \e[32m[๐$PYTHON_VERSION]\e[0m"
134 }
135diff --git a/tests/test_plugin.zunit b/tests/test_plugin.zunit
136index e0daa76b8c3ac4827211ca25e21f53e2e48f4e49..77a6640733e10fa27855483013ace18b99b28868 100644
137--- a/tests/test_plugin.zunit
138+++ b/tests/test_plugin.zunit
139@@ -8,6 +8,8 @@
140 unset VIRTUAL_ENV
141 unset AUTOSWITCH_MESSAGE_FORMAT
142 PYTHON_VERSION="$(python3 --version)"
143+
144+ LANG=".UTF-8"
145 }
146
147 @test 'correct version exported' {
148@@ -36,7 +38,7 @@
149 run load ../autoswitch_virtualenv.plugin.zsh
150
151 assert $status equals 0
152- assert "$output" same_as "Switching virtualenv: \e[1m\e[35mfoobar\e[0m \e[32m[$PYTHON_VERSION]\e[0m"
153+ assert "$output" same_as "Switching virtualenv: \e[1m\e[35mfoobar\e[0m \e[32m[๐$PYTHON_VERSION]\e[0m"
154 }
155
156 @test 'plugin - does nothing if switching to directory without .venv' {
157@@ -62,7 +64,7 @@
158 run cd "$TEMP_DIR"
159
160 assert $status equals 0
161- assert "$output" same_as "Switching virtualenv: \e[1m\e[35mfoobar\e[0m \e[32m[$PYTHON_VERSION]\e[0m"
162+ assert "$output" same_as "Switching virtualenv: \e[1m\e[35mfoobar\e[0m \e[32m[๐$PYTHON_VERSION]\e[0m"
163
164 mkdir "$TEMP_DIR/foo"
165
166@@ -70,5 +72,5 @@
167 run cd "$TEMP_DIR/foo"
168
169 assert $status equals 0
170- assert "$output" same_as "Switching virtualenv: \e[1m\e[35mfoobar\e[0m \e[32m[$PYTHON_VERSION]\e[0m"
171+ assert "$output" same_as "Switching virtualenv: \e[1m\e[35mfoobar\e[0m \e[32m[๐$PYTHON_VERSION]\e[0m"
172 }