90f5bcb9cd875cfa9b38a7409b3628dfe7959d6d

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

Message

Add basic test for poetry support

Diff

 1diff --git a/tests/test_check_venv.zunit b/tests/test_check_venv.zunit
 2index a1194b02108b45a8e3051f0d87059f805b94d5a7..d942a1e99a274590d0f6f57becd9dc3751370a32 100644
 3--- a/tests/test_check_venv.zunit
 4+++ b/tests/test_check_venv.zunit
 5@@ -154,6 +154,25 @@
 6     assert "$output" same_as "Switching virtualenv: \e[1m\e[35mfoodefault\e[0m \e[32m[๐Ÿ$PYTHON_VERSION]\e[0m"
 7 }
 8 
 9+@test 'check_venv - activate if .venv unavailable but poetry available' {
10+    PWD="$TARGET/sub-directory"  # Should also work in subdirectories where pyproject.toml is found
11+    touch "$TARGET/pyproject.toml"
12+
13+    # Mimic poetry run which python
14+    function poetry {
15+        if [[ "$@" == "run which python" ]]; then
16+            echo "$HOME/.virtualenvs/foobar/bin/python"
17+        else
18+            echo "ERROR - wrong command from what was expected ran!"
19+        fi
20+    }
21+
22+    run check_venv
23+
24+    assert $status equals 0
25+    assert "$output" same_as "Switching poetry: \e[1m\e[35mfoobar\e[0m \e[32m[๐Ÿ$PYTHON_VERSION]\e[0m"
26+}
27+
28 
29 @test 'check_venv - activate if .venv unavailable but pipenv available' {
30     PWD="$TARGET/sub-directory"  # Should also work in subdirectories where Pipfile is found