From cea44f118f698046bbd36e9011934d9c2b69ac4a Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Wed, 30 Mar 2022 10:29:03 -0400 Subject: [PATCH] Improve cross-platform Python finder for tests (#176) --- tests/cli/env/test_create.py | 4 ++-- tests/conftest.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/cli/env/test_create.py b/tests/cli/env/test_create.py index 8cedf3fd5..3fa0f68c3 100644 --- a/tests/cli/env/test_create.py +++ b/tests/cli/env/test_create.py @@ -125,7 +125,7 @@ def test_new(hatch, helpers, temp_dir, config_file): assert env_path.name == 'test' -def test_new_selected_python(hatch, helpers, temp_dir, config_file, mocker): +def test_new_selected_python(hatch, helpers, temp_dir, config_file, python_on_path, mocker): mocker.patch('sys.executable') config_file.model.template.plugins['default']['tests'] = False @@ -146,7 +146,7 @@ def test_new_selected_python(hatch, helpers, temp_dir, config_file, mocker): helpers.update_project_environment(project, 'default', {'skip-install': True, **project.config.envs['default']}) helpers.update_project_environment(project, 'test', {}) - with project_path.as_cwd(env_vars={ConfigEnvVars.DATA: str(data_path), AppEnvVars.PYTHON: 'python'}): + with project_path.as_cwd(env_vars={ConfigEnvVars.DATA: str(data_path), AppEnvVars.PYTHON: python_on_path}): result = hatch('env', 'create', 'test') assert result.exit_code == 0, result.output diff --git a/tests/conftest.py b/tests/conftest.py index 3047a6456..d673885a0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -163,6 +163,11 @@ def extract_installed_requirements(helpers, default_virtualenv_installed_require ] +@pytest.fixture(scope='session') +def python_on_path(): + return sys.executable.split(os.sep)[-1] + + @pytest.fixture def mock_backend_process(request, mocker): if 'allow_backend_process' in request.keywords: