|
| 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