Skip to content

Commit 30ab4ee

Browse files
authored
Make test fixtures return each recipe separately (eth-cscs#293)
Makes each test parameterized over the recipe and easier to see which tests pass or fail. Each recipe becomes a separate test
1 parent 2a0a677 commit 30ab4ee

1 file changed

Lines changed: 17 additions & 25 deletions

File tree

unittests/test_schema.py

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,14 @@ def yaml_path(test_path):
2020
return test_path / "yaml"
2121

2222

23-
@pytest.fixture
24-
def recipes():
25-
return [
26-
"host-recipe",
27-
"base-nvgpu",
28-
"cache",
29-
"with-repo",
30-
]
23+
@pytest.fixture(params=["host-recipe", "base-nvgpu", "cache", "with-repo"])
24+
def recipe(request):
25+
return request.param
3126

3227

3328
@pytest.fixture
34-
def recipe_paths(test_path, recipes):
35-
return [test_path / "recipes" / r for r in recipes]
29+
def recipe_path(test_path, recipe):
30+
return test_path / "recipes" / recipe
3631

3732

3833
def test_config_yaml(yaml_path):
@@ -104,12 +99,11 @@ def test_config_yaml(yaml_path):
10499
schema.ConfigValidator.validate(raw)
105100

106101

107-
def test_recipe_config_yaml(recipe_paths):
102+
def test_recipe_config_yaml(recipe_path):
108103
# validate the config.yaml in the test recipes
109-
for p in recipe_paths:
110-
with open(p / "config.yaml") as fid:
111-
raw = yaml.load(fid, Loader=yaml.Loader)
112-
schema.ConfigValidator.validate(raw)
104+
with open(recipe_path / "config.yaml") as fid:
105+
raw = yaml.load(fid, Loader=yaml.Loader)
106+
schema.ConfigValidator.validate(raw)
113107

114108

115109
def test_compilers_yaml(yaml_path):
@@ -128,12 +122,11 @@ def test_compilers_yaml(yaml_path):
128122
assert raw["nvhpc"] == {"version": "25.1"}
129123

130124

131-
def test_recipe_compilers_yaml(recipe_paths):
125+
def test_recipe_compilers_yaml(recipe_path):
132126
# validate the compilers.yaml in the test recipes
133-
for p in recipe_paths:
134-
with open(p / "compilers.yaml") as fid:
135-
raw = yaml.load(fid, Loader=yaml.Loader)
136-
schema.CompilersValidator.validate(raw)
127+
with open(recipe_path / "compilers.yaml") as fid:
128+
raw = yaml.load(fid, Loader=yaml.Loader)
129+
schema.CompilersValidator.validate(raw)
137130

138131

139132
def test_environments_yaml(yaml_path):
@@ -189,12 +182,11 @@ def test_environments_yaml(yaml_path):
189182
schema.EnvironmentsValidator.validate(raw)
190183

191184

192-
def test_recipe_environments_yaml(recipe_paths):
185+
def test_recipe_environments_yaml(recipe_path):
193186
# validate the environments.yaml in the test recipes
194-
for p in recipe_paths:
195-
with open(p / "environments.yaml") as fid:
196-
raw = yaml.load(fid, Loader=yaml.Loader)
197-
schema.EnvironmentsValidator.validate(raw)
187+
with open(recipe_path / "environments.yaml") as fid:
188+
raw = yaml.load(fid, Loader=yaml.Loader)
189+
schema.EnvironmentsValidator.validate(raw)
198190

199191

200192
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)