Skip to content

Commit 807d1d9

Browse files
committed
new test added
1 parent 5425e09 commit 807d1d9

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

conan/tools/system/pip_manager.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ def _create_venv(self):
2929
python_interpreter = self._conanfile.conf.get("tools.system.pipenv:python_interpreter",
3030
default=os.path.realpath(default_python) if default_python else None)
3131
if not python_interpreter:
32-
raise ConanException("PipEnv could not find a Python executable path.")
32+
raise ConanException("PipEnv could not find a Python executable path."
33+
"Please set 'tools.system.pipenv:python_interpreter' to '</your/python/full/path>' "
34+
"in the [conf] section of the profile, or in the command line using "
35+
"'-c tools.system.pipenv:python_interpreter=</your/python/full/path>'")
3336

3437
try:
3538
self._conanfile.run(cmd_args_to_string([python_interpreter, '-m', 'venv', self._env_dir]))
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from conan.tools.system import PipEnv
2+
from unittest.mock import patch
3+
import mock
4+
import pytest
5+
from unittest.mock import PropertyMock
6+
from conan.errors import ConanException
7+
from conan.internal.model.settings import Settings
8+
from conan.test.utils.mocks import ConanFileMock
9+
10+
11+
def test_pipenv_conf():
12+
# https://github.com/conan-io/conan/issues/11661
13+
conanfile = ConanFileMock()
14+
conanfile.settings = Settings()
15+
conanfile.conf.define("tools.system.pipenv:python_interpreter", "/python/interpreter/from/config")
16+
result = "/python/interpreter/from/config -m venv /Users/davidsanfal/repos/github/conan-io/testenv/pip_venv_None"
17+
pipenv = PipEnv(conanfile, "testenv")
18+
19+
def fake_run(command, win_bash=False, subsystem=None, env=None, ignore_errors=False, quiet=False):
20+
assert command == result
21+
return 100
22+
conanfile.run = fake_run
23+
pipenv._create_venv()
24+
25+
26+
@patch('shutil.which')
27+
def test_pipenv_error_message(mock_shutil_which):
28+
# https://github.com/conan-io/conan/issues/11661
29+
conanfile = ConanFileMock()
30+
conanfile.settings = Settings()
31+
mock_shutil_which.return_value = None
32+
with pytest.raises(ConanException) as exc_info:
33+
pipenv = PipEnv(conanfile, "testenv")
34+
pipenv._create_venv()
35+
assert exc_info.value.args[0] == "PipEnv could not find a Python executable path." \
36+
"Please set 'tools.system.pipenv:python_interpreter' to '</your/python/full/path>' " \
37+
"in the [conf] section of the profile, or in the command line using " \
38+
"'-c tools.system.pipenv:python_interpreter=</your/python/full/path>'"

0 commit comments

Comments
 (0)