996fcceaef82e45b79ac1d3d711b351f90fc8083
- Author
- Michael Aquilina <michaelaquilina@gmail.com>
- Committer
- Michael Aquilina <michaelaquilina@gmail.com>
- Date
Message
Add test for deactivating pipenv
Diff
1diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
2index 8e2257fe41a364421d00ad1a679ac1eb6be437a7..fc672267d0fa0e6e00205c93ce36f1120f689db0 100644
3--- a/autoswitch_virtualenv.plugin.zsh
4+++ b/autoswitch_virtualenv.plugin.zsh
5@@ -170,7 +170,7 @@ function _default_venv()
6 if [[ -n "$AUTOSWITCH_DEFAULTENV" ]]; then
7 _maybeworkon "$(_virtual_env_dir "$AUTOSWITCH_DEFAULTENV")" "$venv_type"
8 elif [[ -n "$VIRTUAL_ENV" ]]; then
9- local venv_name="$(_get_venv_name "$VIRTUAL_ENV")"
10+ local venv_name="$(_get_venv_name "$VIRTUAL_ENV" "$venv_type")"
11 _autoswitch_message "Deactivating: ${BOLD}${PURPLE}%s${NORMAL}\n" "$venv_name"
12 deactivate
13 fi
14diff --git a/tests/test_check_venv.zunit b/tests/test_check_venv.zunit
15index ae0754202c076d31872fd7a1ec3d3e8760a88fc6..7cf209224ba7d661abdd3c329f5807453db8788e 100644
16--- a/tests/test_check_venv.zunit
17+++ b/tests/test_check_venv.zunit
18@@ -17,11 +17,13 @@
19 export DISABLE_AUTOSWITCH_VENV="1"
20 load "../autoswitch_virtualenv.plugin.zsh"
21 TARGET="$(mktemp -d)"
22+ OLDPWD="$(mktemp -d)"
23 }
24
25
26 @teardown {
27 rm -rf "$TARGET"
28+ rm -rf "$OLDPWD"
29 rm -rf Pipfile
30 }
31
32@@ -180,6 +182,20 @@
33 assert "$output" same_as "Deactivating: \e[1m\e[35mfoo\e[0m"
34 }
35
36+@test 'check_venv - deactivate if neither .venv nor pipenv available (previous dir is pipenv)' {
37+ PWD="$TARGET"
38+ touch "$OLDPWD/Pipfile"
39+
40+ VIRTUAL_ENV="foo-bar-defa23"
41+ unset AUTOSWITCH_DEFAULTENV
42+ function deactivate {
43+ }
44+
45+ run check_venv
46+
47+ assert $status equals 0
48+ assert "$output" same_as "Deactivating: \e[1m\e[35mfoo-bar\e[0m"
49+}
50
51 @test 'check_venv - works as intended with .venv available' {
52 PWD="$TARGET"