Skip to content

Commit

Permalink
TST: Use alternate environments correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoZeke committed Nov 25, 2024
1 parent e2813fe commit edf5b1f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
5 changes: 4 additions & 1 deletion test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand Down
16 changes: 12 additions & 4 deletions test/test_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)

Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)

Expand All @@ -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)

Expand Down

0 comments on commit edf5b1f

Please sign in to comment.