8fd23f81bd5195b097385d6c8ba8c59a833a6c36

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

Message

Merge pull request #104 from MichaelAquilina/next

1.12.0 release

Diff

  1diff --git a/CHANGELOG.rst b/CHANGELOG.rst
  2index fec42e74a47fca49d231677bdb3f76310ecc735f..5bc2cd3936eb33f3b57b7b983929409ea400644a 100644
  3--- a/CHANGELOG.rst
  4+++ b/CHANGELOG.rst
  5@@ -1,6 +1,10 @@
  6 Changelog
  7 =========
  8 
  9+1.12.0
 10+------
 11+* Remove virtualenv requirement. This is now only needed for running mkvenv
 12+
 13 1.11.1
 14 ------
 15 * Fix bug with pipenv detection where extra messages would be incorrectly displayed
 16diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
 17index 7616b3e8298cdd87542ec3a6e09eaa783fcb783a..1ec1483be13cf33d7d56ed90c3406a47536d3e46 100644
 18--- a/autoswitch_virtualenv.plugin.zsh
 19+++ b/autoswitch_virtualenv.plugin.zsh
 20@@ -1,4 +1,4 @@
 21-export AUTOSWITCH_VERSION='1.11.1'
 22+export AUTOSWITCH_VERSION='1.12.0'
 23 
 24 RED="\e[31m"
 25 GREEN="\e[32m"
 26@@ -177,6 +177,16 @@ function rmvenv()
 27 # helper function to create a virtual environment for the current directory
 28 function mkvenv()
 29 {
 30+    if ! type "virtualenv" > /dev/null; then
 31+        printf "${BOLD}${RED}"
 32+        printf "zsh-autoswitch-virtualenv requires virtualenv to be installed!\n\n"
 33+        printf "${NORMAL}"
 34+        printf "If this is already installed but you are still seeing this message, \n"
 35+        printf "then make sure the ${BOLD}virtualenv${NORMAL} command is in your PATH.\n"
 36+        printf "\n"
 37+        return
 38+    fi
 39+
 40     if [[ -f ".venv" ]]; then
 41         printf ".venv file already exists. If this is a mistake use the rmvenv command\n"
 42     else
 43@@ -257,14 +267,5 @@ function disable_autoswitch_virtualenv() {
 44 }
 45 
 46 
 47-if ! type "virtualenv" > /dev/null; then
 48-    printf "${BOLD}${RED}"
 49-    printf "zsh-autoswitch-virtualenv requires virtualenv to be installed!\n\n"
 50-    printf "${NORMAL}"
 51-    printf "If this is already installed but you are still seeing this message, \n"
 52-    printf "then make sure the ${BOLD}virtualenv${NORMAL} command is in your PATH.\n"
 53-    printf "\n"
 54-else
 55-    enable_autoswitch_virtualenv
 56-    check_venv
 57-fi
 58+enable_autoswitch_virtualenv
 59+check_venv
 60diff --git a/tests/test_help.zunit b/tests/test_help.zunit
 61index d31bc1375c0649abf1f6281725066aceea3ed925..c74cb0a70c57f14d25b734f17c0b95ea2a8ce96f 100644
 62--- a/tests/test_help.zunit
 63+++ b/tests/test_help.zunit
 64@@ -1,21 +1 @@
 65 #!/usr/bin/env zunit
 66-
 67-@test 'prints help message and disables plugin if virtualenv not setup' {
 68-    # Mock type to fail
 69-    function type() {
 70-        if [[ "$1" == "virtualenv" ]]; then
 71-            return 1
 72-        fi
 73-        return 0
 74-    }
 75-
 76-    run load ../autoswitch_virtualenv.plugin.zsh
 77-
 78-    assert $status equals 0
 79-    assert "$lines[1]" contains "zsh-autoswitch-virtualenv requires virtualenv to be installed!"
 80-    assert "$lines[2]" is_empty
 81-    assert "$lines[3]" contains "If this is already installed but you are still seeing this message,"
 82-    assert "$lines[4]" contains "then make sure the \e[1mvirtualenv\e[0m command is in your PATH.\n"
 83-    assert "$lines[5]" is_empty
 84-    assert ${#lines} equals 4
 85-}
 86diff --git a/tests/test_mkvenv.zunit b/tests/test_mkvenv.zunit
 87index 530319a2a186ea26a7b54c2bede4edadb9f4fa5d..9b08b8eedcbe20946093e1368ab53cb6cf74cf6d 100644
 88--- a/tests/test_mkvenv.zunit
 89+++ b/tests/test_mkvenv.zunit
 90@@ -1,6 +1,9 @@
 91 #!/usr/bin/env zunit
 92 
 93 @setup {
 94+    function virtualenv {
 95+        echo virtualenv $@
 96+    }
 97 
 98     export DISABLE_AUTOSWITCH_VENV="1"
 99     load "../autoswitch_virtualenv.plugin.zsh"
100@@ -40,11 +43,6 @@
101 }
102 
103 @test 'mkvenv - uses default python if set and not specified' {
104-    # mock virtualenv function to test its inputs
105-    function virtualenv {
106-        echo virtualenv $@
107-    }
108-
109     mkdir myproject
110     cd myproject
111     AUTOSWITCH_DEFAULT_PYTHON="python_foo"
112@@ -84,3 +82,23 @@
113     assert $status equals 0
114     assert "$output" same_as "myproject"
115 }
116+
117+@test 'prints help message and disables plugin if virtualenv not setup' {
118+    # Mock type to fail
119+    function type() {
120+        if [[ "$1" == "virtualenv" ]]; then
121+            return 1
122+        fi
123+        return 0
124+    }
125+
126+    run mkvenv
127+
128+    assert $status equals 0
129+    assert "$lines[1]" contains "zsh-autoswitch-virtualenv requires virtualenv to be installed!"
130+    assert "$lines[2]" is_empty
131+    assert "$lines[3]" contains "If this is already installed but you are still seeing this message,"
132+    assert "$lines[4]" contains "then make sure the \e[1mvirtualenv\e[0m command is in your PATH.\n"
133+    assert "$lines[5]" is_empty
134+    assert ${#lines} equals 4
135+}