Skip to content

Commit 283dc65

Browse files
authored
Extract test_module_dependencies_complete into its own file (#1803)
1 parent 35a24ec commit 283dc65

File tree

2 files changed

+50
-35
lines changed

2 files changed

+50
-35
lines changed

tests/test_module_dependencies.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -207,41 +207,6 @@ def test_module_dependencies_allow_initialisation(sim, module_class):
207207
)
208208

209209

210-
@pytest.mark.slow
211-
@parameterize_module_class
212-
def test_module_dependencies_complete(sim, module_class):
213-
"""Check declared dependencies are sufficient for successful (short) simulation.
214-
215-
Dependencies here refers to the union of INIT_DEPENDENCIES and
216-
ADDITIONAL_DEPENDENCIES.
217-
"""
218-
try:
219-
# If this module is an 'alternative' to one or more other modules, exclude these
220-
# modules from being selected to avoid clashes with this module
221-
excluded_module_classes = {
222-
module_class_map[module_name] for module_name in module_class.ALTERNATIVE_TO
223-
}
224-
register_modules_and_simulate(
225-
sim,
226-
get_dependencies_and_initialise(
227-
module_class,
228-
module_class_map=module_class_map,
229-
get_dependencies=get_all_dependencies,
230-
excluded_module_classes=excluded_module_classes,
231-
resourcefilepath=resourcefilepath
232-
),
233-
check_all_dependencies=True
234-
)
235-
except Exception:
236-
all_dependencies = get_all_required_dependencies(module_class)
237-
pytest.fail(
238-
f"Module {module_class.__name__} appears to be missing dependencies "
239-
f"required to run simulation in the union of the INIT_DEPENDENCIES and "
240-
f"ADDITIONAL_DEPENDENCIES class attributes which is currently "
241-
f"{{{', '.join(all_dependencies)}}}."
242-
)
243-
244-
245210
@pytest.mark.parametrize(
246211
"module_and_dependency_pair",
247212
[
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import pytest
2+
from test_module_dependencies import (
3+
module_class_map,
4+
parameterize_module_class,
5+
register_modules_and_simulate,
6+
resourcefilepath,
7+
)
8+
from test_module_dependencies import sim as get_simulation # to silence unused import warning
9+
10+
from tlo.dependencies import (
11+
get_all_dependencies,
12+
get_all_required_dependencies,
13+
get_dependencies_and_initialise,
14+
)
15+
16+
sim = get_simulation # pytest fixture
17+
18+
@pytest.mark.slow
19+
@parameterize_module_class
20+
def test_module_dependencies_complete(sim, module_class):
21+
"""Check declared dependencies are sufficient for successful (short) simulation.
22+
23+
Dependencies here refers to the union of INIT_DEPENDENCIES and
24+
ADDITIONAL_DEPENDENCIES.
25+
"""
26+
try:
27+
# If this module is an 'alternative' to one or more other modules, exclude these
28+
# modules from being selected to avoid clashes with this module
29+
excluded_module_classes = {
30+
module_class_map[module_name] for module_name in module_class.ALTERNATIVE_TO
31+
}
32+
register_modules_and_simulate(
33+
sim,
34+
get_dependencies_and_initialise(
35+
module_class,
36+
module_class_map=module_class_map,
37+
get_dependencies=get_all_dependencies,
38+
excluded_module_classes=excluded_module_classes,
39+
resourcefilepath=resourcefilepath
40+
),
41+
check_all_dependencies=True
42+
)
43+
except Exception:
44+
all_dependencies = get_all_required_dependencies(module_class)
45+
pytest.fail(
46+
f"Module {module_class.__name__} appears to be missing dependencies "
47+
f"required to run simulation in the union of the INIT_DEPENDENCIES and "
48+
f"ADDITIONAL_DEPENDENCIES class attributes which is currently "
49+
f"{{{', '.join(all_dependencies)}}}."
50+
)

0 commit comments

Comments
 (0)