Skip to content

Commit

Permalink
BUG: Fix alternate environment logic in tests
Browse files Browse the repository at this point in the history
In a pretty hacky way, also part of airspeed-velocitygh-1446
  • Loading branch information
HaoZeke committed Nov 25, 2024
1 parent edf5b1f commit 57d9c36
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion asv/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def get_environment_class(conf, python):
classes.insert(0, cls)

for cls in classes:
if cls.matches_python_fallback and cls.matches(python):
if cls.matches_python_fallback or cls.matches(python):
return cls
raise EnvironmentUnavailable(
f"No way to create environment for python='{python}'")
Expand Down
12 changes: 8 additions & 4 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,29 @@ def generate_basic_conf(tmpdir,
# values not in test_dev.py copy
repo_path = tools.generate_test_repo(tmpdir, values,
subdir=repo_subdir).path
global env_type

conf_dict = {
'env_dir': 'env',
'benchmark_dir': 'benchmark',
'results_dir': 'results_workflow',
'html_dir': 'html',
'repo': relpath(repo_path),
'environment_type': env_type,
'project': 'asv',
'conda_channels': ["conda-forge"],
'dvcs': 'git',
'matrix': {
"asv-dummy-test-package-1": [None],
"asv-dummy-test-package-2": tools.DUMMY2_VERSIONS,
"pip+asv-dummy-test-package-1": [None],
"pip+asv-dummy-test-package-2": tools.DUMMY2_VERSIONS,
},
}
if not dummy_packages:
conf_dict['matrix'] = {}
elif conf_version == 2:
conf_dict['matrix'] = {
"asv_dummy_test_package_1": [""],
"asv_dummy_test_package_2": tools.DUMMY2_VERSIONS,
"pip+asv_dummy_test_package_1": [""],
"pip+asv_dummy_test_package_2": tools.DUMMY2_VERSIONS,
}
if repo_subdir:
conf_dict['repo_subdir'] = repo_subdir
Expand All @@ -112,6 +114,8 @@ def pytest_sessionstart(session):
_monkeypatch_conda_lock(session.config)

# Unregister unwanted environment types
# XXX: Ugly hack to get the variable into generate_basic_conf
global env_type
env_type = session.config.getoption('environment_type')
if env_type is not None:
import asv.environment
Expand Down

0 comments on commit 57d9c36

Please sign in to comment.