Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve cross-platform Python finder for tests #176

Merged
merged 1 commit into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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