Commit ed5441f5 by finswimmer Committed by Randy Döring

fix(env): catch EnvCommandError instead of CalledProcessError when detecting active python

parent be8cd1fb
...@@ -551,7 +551,7 @@ class EnvManager: ...@@ -551,7 +551,7 @@ class EnvManager:
self._io.write_error_line( self._io.write_error_line(
f"Found: {executable}", verbosity=Verbosity.VERBOSE f"Found: {executable}", verbosity=Verbosity.VERBOSE
) )
except CalledProcessError: except EnvCommandError:
self._io.write_error_line( self._io.write_error_line(
( (
"Unable to detect the current active python executable. Falling" "Unable to detect the current active python executable. Falling"
......
...@@ -1601,3 +1601,15 @@ def test_create_venv_project_name_empty_sets_correct_prompt( ...@@ -1601,3 +1601,15 @@ def test_create_venv_project_name_empty_sets_correct_prompt(
}, },
prompt="virtualenv-py3.7", prompt="virtualenv-py3.7",
) )
def test_fallback_on_detect_active_python(poetry: Poetry, mocker: MockerFixture):
m = mocker.patch(
"subprocess.check_output",
side_effect=subprocess.CalledProcessError(1, "some command"),
)
env_manager = EnvManager(poetry)
active_python = env_manager._detect_active_python()
assert active_python is None
assert m.call_count == 1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment