add pytest-lazy-fixtures; parametrized recipes
MODIFY
dev-requirements.txt
dev-requirements.txt
pytest
pytest-sugar
pytest-cov
+pytest-lazy-fixture
scipy
netcdf4
h5netcdf

MODIFY
tests/conftest.py
tests/conftest.py
@@ -182,17 +182,22 @@ def netCDFtoZarr_sequential_multi_variable_recipe(
daily_xarray_dataset, netcdf_local_paths_by_variable, tmp_target, tmp_cache
):
paths, items_per_file, fnames_by_variable, path_format = netcdf_local_paths_by_variable
- timesteps = np.arange(len(paths) / 2)
+ nitems_per_input = items_per_file
+ metadata_cache = None
+ target_chunks = {}
+ time_index = list(range(len(paths) // 2))
pattern = VariableSequencePattern(
- path_format, keys={"variable": ["foo", "bar"], "n": timesteps}
+ path_format, keys={"variable": ["foo", "bar"], "n": time_index}
)
kwargs = dict(
input_pattern=pattern,
sequence_dim="time",
inputs_per_chunk=1,
- nitems_per_input=items_per_file,
+ nitems_per_input=nitems_per_input,
target=tmp_target,
input_cache=tmp_cache,
+ metadata_cache=metadata_cache,
+ target_chunks=target_chunks,
)
return recipe.NetCDFtoZarrMultiVarSequentialRecipe, kwargs, daily_xarray_dataset, tmp_target

MODIFY
tests/test_executors.py
tests/test_executors.py
+import pytest
import xarray as xr
-def test_recipe_w_executor(netCDFtoZarr_sequential_recipe, execute_recipe):
- Recipe, kwargs, ds_expected, target = netCDFtoZarr_sequential_recipe
- rec = Recipe(**kwargs)
+@pytest.mark.parametrize(
+ "recipe_fixture",
+ [
+ pytest.lazy_fixture("netCDFtoZarr_sequential_recipe"),
+ pytest.lazy_fixture("netCDFtoZarr_sequential_multi_variable_recipe"),
+ ],
+)
+def test_recipe_w_executor(recipe_fixture, execute_recipe):
+ RecipeClass, kwargs, ds_expected, target = recipe_fixture
+ rec = RecipeClass(**kwargs)
execute_recipe(rec)
ds_actual = xr.open_zarr(target.get_mapper()).load()
assert ds_actual.identical(ds_expected)

add pytest-lazy-fixtures; parametrized recipes