From edf5b1f50795225dda788d837b2e0699f6e95a1a Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Mon, 25 Nov 2024 04:47:39 +0000 Subject: [PATCH] TST: Use alternate environments correctly Closes gh-1446 --- test/conftest.py | 5 ++++- test/test_benchmarks.py | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/test/conftest.py b/test/conftest.py index 5e38c16e6..cc4e9bba8 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -83,6 +83,7 @@ def generate_basic_conf(tmpdir, 'html_dir': 'html', 'repo': relpath(repo_path), 'project': 'asv', + 'conda_channels': ["conda-forge"], 'dvcs': 'git', 'matrix': { "asv-dummy-test-package-1": [None], @@ -343,7 +344,7 @@ def basic_html(request): @pytest.fixture -def benchmarks_fixture(tmpdir): +def benchmarks_fixture(tmpdir, request: pytest.FixtureRequest): tmpdir = str(tmpdir) os.chdir(tmpdir) @@ -353,6 +354,8 @@ def benchmarks_fixture(tmpdir): d.update(ASV_CONF_JSON) d['env_dir'] = "env" d['benchmark_dir'] = 'benchmark' + d['environment_type'] = request.config.getoption('environment_type') + d['conda_channels'] = ["conda-forge"] d['repo'] = tools.generate_test_repo(tmpdir, [0]).path d['branches'] = ["master"] conf = config.Config.from_json(d) diff --git a/test/test_benchmarks.py b/test/test_benchmarks.py index 0303ff086..8692da516 100644 --- a/test/test_benchmarks.py +++ b/test/test_benchmarks.py @@ -115,7 +115,7 @@ def test_invalid_benchmark_tree(tmpdir): benchmarks.Benchmarks.discover(conf, repo, envs, [commit_hash]) -def test_find_benchmarks_cwd_imports(tmpdir): +def test_find_benchmarks_cwd_imports(tmpdir, request: pytest.FixtureRequest): # Test that files in the directory above the benchmark suite are # not importable @@ -144,6 +144,8 @@ def track_this(): d = {} d.update(ASV_CONF_JSON) d['env_dir'] = "env" + d['environment_type'] = request.config.getoption('environment_type') + d['conda_channels'] = ["conda-forge"] d['benchmark_dir'] = 'benchmark' d['repo'] = tools.generate_test_repo(tmpdir, [[0, 1]]).path conf = config.Config.from_json(d) @@ -157,7 +159,7 @@ def track_this(): assert len(b) == 1 -def test_import_failure_retry(tmpdir): +def test_import_failure_retry(tmpdir, request: pytest.FixtureRequest): # Test that a different commit is tried on import failure tmpdir = str(tmpdir) @@ -183,6 +185,8 @@ def time_foo(): d.update(ASV_CONF_JSON) d['env_dir'] = "env" d['benchmark_dir'] = 'benchmark' + d['environment_type'] = request.config.getoption('environment_type') + d['conda_channels'] = ["conda-forge"] d['repo'] = dvcs.path conf = config.Config.from_json(d) @@ -195,7 +199,7 @@ def time_foo(): assert b['time_foo']['number'] == 1 -def test_conf_inside_benchmarks_dir(tmpdir): +def test_conf_inside_benchmarks_dir(tmpdir, request: pytest.FixtureRequest): # Test that the configuration file can be inside the benchmark suite tmpdir = str(tmpdir) @@ -212,6 +216,8 @@ def test_conf_inside_benchmarks_dir(tmpdir): d = {} d.update(ASV_CONF_JSON) d['env_dir'] = "env" + d['environment_type'] = request.config.getoption('environment_type') + d['conda_channels'] = ["conda-forge"] d['benchmark_dir'] = '.' d['repo'] = tools.generate_test_repo(tmpdir, [[0, 1]]).path conf = config.Config.from_json(d) @@ -228,7 +234,7 @@ def test_conf_inside_benchmarks_dir(tmpdir): assert set(b.keys()) == {'track_this', 'bench.track_this'} -def test_code_extraction(tmpdir): +def test_code_extraction(tmpdir, request: pytest.FixtureRequest): tmpdir = str(tmpdir) os.chdir(tmpdir) @@ -238,6 +244,8 @@ def test_code_extraction(tmpdir): d.update(ASV_CONF_JSON) d['env_dir'] = "env" d['benchmark_dir'] = 'benchmark' + d['environment_type'] = request.config.getoption('environment_type') + d['conda_channels'] = ["conda-forge"] d['repo'] = tools.generate_test_repo(tmpdir, [0]).path conf = config.Config.from_json(d)