factor execution fixture into separate fixtures, then reassemble lazy fixture
MODIFY
tests/conftest.py
tests/conftest.py
@@ -403,9 +403,8 @@ _executors = {
}
-@pytest.fixture(params=["manual", "python", "dask", "prefect", "prefect-dask"])
-def execute_recipe(request, dask_cluster):
- if request.param == "manual":
+@pytest.fixture()
+def execute_recipe_manual():
def execute(r):
if r.cache_inputs:
@@ -416,26 +415,41 @@ def execute_recipe(request, dask_cluster):
r.store_chunk(chunk_key)
r.finalize_target()
- elif request.param == "python":
+ return execute
+
+
+@pytest.fixture()
+def execute_recipe_python():
def execute(recipe):
return recipe.to_function()()
- elif request.param == "dask":
+ return execute
+
+
+@pytest.fixture()
+def execute_recipe_dask(dask_cluster):
def execute(recipe):
with Client(dask_cluster):
return recipe.to_dask().compute()
- elif request.param == "prefect":
+ return execute
+
+
+@pytest.fixture()
+def execute_recipe_prefect():
def execute(recipe):
state = recipe.to_prefect().run()
if state.is_failed():
raise ValueError(f"Prefect flow run failed with message {state.message}")
- else:
- assert request.param == "prefect-dask"
+ return execute
+
+
+@pytest.fixture()
+def execute_recipe_prefect_dask(dask_cluster):
def execute(recipe):
flow = recipe.to_prefect()
@@ -444,5 +458,35 @@ def execute_recipe(request, dask_cluster):
if state.is_failed():
raise ValueError(f"Prefect flow run failed with message {state.message}")
- execute.param = request.param
return execute
+
+
+@pytest.fixture(
+ params=[
+ lazy_fixture("execute_recipe_manual"),
+ lazy_fixture("execute_recipe_python"),
+ lazy_fixture("execute_recipe_dask"),
+ ],
+)
+def execute_recipe_no_prefect(request):
+ return request.param
+
+
+@pytest.fixture(
+ params=[
+ lazy_fixture("execute_recipe_prefect"),
+ lazy_fixture("execute_recipe_prefect_dask"),
+ ],
+)
+def execute_recipe_with_prefect(request):
+ return request.param
+
+
+@pytest.fixture(
+ params=[
+ lazy_fixture("execute_recipe_no_prefect"),
+ lazy_fixture("execute_recipe_with_prefect"),
+ ],
+)
+def execute_recipe(request):
+ return request.param

factor execution fixture into separate fixtures, then reassemble lazy fixture