9ceb1168c61a3afb5405b350a14dd71384c62af5

Author
Michael Aquilina <michaelaquilina@gmail.com>
Committer
Michael Aquilina <michaelaquilina@gmail.com>
Date

Message

Color the displayed python version

Diff

  1diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
  2index e248e440f0c8980cfe7a63f1fd7ba7c360d7ed77..88b8092060178c36ae97fe8c263321e9590ae207 100644
  3--- a/autoswitch_virtualenv.plugin.zsh
  4+++ b/autoswitch_virtualenv.plugin.zsh
  5@@ -20,9 +20,9 @@ fi
  6 function _print_python_version() {
  7    # For some reason python --version writes to stderr
  8    if type python > /dev/null; then
  9-       printf "[%s]\n" "$(python --version 2>&1)"
 10+       printf "\e[32m[%s]\e[0m\n" "$(python --version 2>&1)"
 11    elif type python3 > /dev/null; then
 12-       printf "[%s]\n" "$(python3 --version 2>&1)"
 13+       printf "\e[32m[%s][\[0m\n" "$(python3 --version 2>&1)"
 14    else
 15        printf "Unable to find python installed on this machine"
 16     fi
 17diff --git a/tests/test_check_venv.zunit b/tests/test_check_venv.zunit
 18index 3bc7decfedda017d073847ceca7aac7b80eb7bfa..9d11970afe8acb5b2d0329079a074597101821ef 100644
 19--- a/tests/test_check_venv.zunit
 20+++ b/tests/test_check_venv.zunit
 21@@ -69,7 +69,7 @@
 22     run check_venv
 23 
 24     assert $status equals 0
 25-    assert "$output" same_as "Switching virtualenv: foobar  [$PYTHON_VERSION]"
 26+    assert "$output" same_as "Switching virtualenv: foobar  \e[32m[$PYTHON_VERSION]\e[0m"
 27 }
 28 
 29 @test 'check_venv - No security warning for readable by group permission' {
 30@@ -84,7 +84,7 @@
 31     run check_venv
 32 
 33     assert $status equals 0
 34-    assert "$output" same_as "Switching virtualenv: foobar  [$PYTHON_VERSION]"
 35+    assert "$output" same_as "Switching virtualenv: foobar  \e[32m[$PYTHON_VERSION]\e[0m"
 36 }
 37 
 38 @test 'check_venv - No security warning for readable only by owner permission' {
 39@@ -98,7 +98,7 @@
 40     run check_venv
 41 
 42     assert $status equals 0
 43-    assert "$output" same_as "Switching virtualenv: foobar  [$PYTHON_VERSION]"
 44+    assert "$output" same_as "Switching virtualenv: foobar  \e[32m[$PYTHON_VERSION]\e[0m"
 45 }
 46 
 47 
 48@@ -124,7 +124,7 @@
 49     run check_venv
 50 
 51     assert $status equals 0
 52-    assert "$output" same_as "Switching virtualenv: foodefault  [$PYTHON_VERSION]"
 53+    assert "$output" same_as "Switching virtualenv: foodefault  \e[32m[$PYTHON_VERSION]\e[0m"
 54 }
 55 
 56 
 57@@ -140,7 +140,7 @@
 58     run check_venv
 59 
 60     assert $status equals 0
 61-    assert "$output" same_as "Switching pipenv: foobar  [$PYTHON_VERSION]"
 62+    assert "$output" same_as "Switching pipenv: foobar  \e[32m[$PYTHON_VERSION]\e[0m"
 63 }
 64 
 65 
 66@@ -170,5 +170,5 @@
 67     run check_venv
 68 
 69     assert $status equals 0
 70-    assert "$output" same_as "Switching virtualenv: foobar  [$PYTHON_VERSION]"
 71+    assert "$output" same_as "Switching virtualenv: foobar  \e[32m[$PYTHON_VERSION]\e[0m"
 72 }
 73diff --git a/tests/test_maybepipenv.zunit b/tests/test_maybepipenv.zunit
 74index 655fbd2d6b01d5c9cf03897dd8ae97a747c09f52..50cb6bd57a6cb32e2cafee10e799a70309715737 100644
 75--- a/tests/test_maybepipenv.zunit
 76+++ b/tests/test_maybepipenv.zunit
 77@@ -27,9 +27,7 @@
 78     run _maybepipenv "$(pipenv --venv)"
 79 
 80     assert $state equals 0
 81-    assert "$output" matches "Switching pipenv: $(basename "$PWD")-[^\s]{8}  \[$PYTHON_VERSION\]"
 82-
 83-
 84+    assert "$output" matches "Switching pipenv: $(basename "$PWD")-[^\s]{8}"
 85 }
 86 
 87 @test '_maybepipenv - switches virtualenv if current virtualenv is different' {
 88@@ -38,7 +36,7 @@
 89     run _maybepipenv "$(pipenv --venv)"
 90 
 91     assert $state equals 0
 92-    assert "$output" matches "Switching pipenv: $(basename "$PWD")-[^\s]{8}  \[$PYTHON_VERSION\]"
 93+    assert "$output" matches "Switching pipenv: $(basename "$PWD")-[^\s]{8}"
 94 }
 95 
 96 @test '_maybepipenv - switches virtualenv if current virtualenv is different (silent)' {
 97diff --git a/tests/test_maybeworkon.zunit b/tests/test_maybeworkon.zunit
 98index bac535b930523447b6b8d60430a46a94f1f678c9..519a58deddea04836ddcc2f6567ca38bedd663ee 100644
 99--- a/tests/test_maybeworkon.zunit
100+++ b/tests/test_maybeworkon.zunit
101@@ -27,7 +27,7 @@
102     run _maybeworkon foobar
103 
104     assert $state equals 0
105-    assert "$output" same_as "Switching virtualenv: foobar  [$PYTHON_VERSION]"
106+    assert "$output" same_as "Switching virtualenv: foobar  \e[32m[$PYTHON_VERSION]\e[0m"
107 }
108 
109 @test '_maybeworkon - switches virtualenv if current virtualenv is different' {
110@@ -36,7 +36,7 @@
111     run _maybeworkon foobar
112 
113     assert $state equals 0
114-    assert "$output" contains "Switching virtualenv: foobar  [$PYTHON_VERSION]"
115+    assert "$output" contains "Switching virtualenv: foobar  \e[32m[$PYTHON_VERSION]\e[0m"
116 }
117 
118 @test '_maybeworkon - switches virtualenv if current virtualenv is different (silent)' {
119diff --git a/tests/test_plugin.zunit b/tests/test_plugin.zunit
120index 3a09cdfdb6978425ed88eb19f196940429c14401..dfa917ab0ae91cf4648ad429c3471ebc3dc6b975 100644
121--- a/tests/test_plugin.zunit
122+++ b/tests/test_plugin.zunit
123@@ -37,7 +37,7 @@
124     run load ../autoswitch_virtualenv.plugin.zsh
125 
126     assert $status equals 0
127-    assert "$output" same_as "Switching virtualenv: foobar  [$PYTHON_VERSION]"
128+    assert "$output" same_as "Switching virtualenv: foobar  \e[32m[$PYTHON_VERSION]\e[0m"
129 }
130 
131 @test 'plugin - does nothing if switching to directory without .venv' {
132@@ -63,7 +63,7 @@
133     run cd "$TEMP_DIR"
134 
135     assert $status equals 0
136-    assert "$output" same_as "Switching virtualenv: foobar  [$PYTHON_VERSION]"
137+    assert "$output" same_as "Switching virtualenv: foobar  \e[32m[$PYTHON_VERSION]\e[0m"
138 
139     mkdir "$TEMP_DIR/foo"
140 
141@@ -71,5 +71,5 @@
142     run cd "$TEMP_DIR/foo"
143 
144     assert $status equals 0
145-    assert "$output" same_as "Switching virtualenv: foobar  [$PYTHON_VERSION]"
146+    assert "$output" same_as "Switching virtualenv: foobar  \e[32m[$PYTHON_VERSION]\e[0m"
147 }