Skip to content

Commit

Permalink
Improve cross-platform Python finder for tests (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek authored Mar 30, 2022
1 parent 501be34 commit cea44f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/cli/env/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit cea44f1

Please sign in to comment.