-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
52 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from importlib import import_module | ||
from inspect import signature | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from faker import Faker | ||
|
||
from ice.paper import Paper | ||
from ice.recipe import FunctionBasedRecipe | ||
from ice.recipe import recipe | ||
|
||
Faker.seed(0) | ||
fake = Faker() | ||
|
||
|
||
root_dir = Path(__file__).parent.parent | ||
|
||
primer_recipes_dir = root_dir / "ice" / "recipes" / "primer" | ||
for path in primer_recipes_dir.glob("**/*.py"): | ||
relative_path = path.relative_to(primer_recipes_dir) | ||
module_name = ".".join(relative_path.parts[:-1] + (relative_path.stem,)) | ||
import_module(f"ice.recipes.primer.{module_name}") | ||
|
||
paper = Paper.load(Path(root_dir / "papers" / "keenan-2018-tiny.txt")) | ||
|
||
|
||
@pytest.mark.parametrize("main", recipe.all_recipes) | ||
@pytest.mark.anyio | ||
async def test_all_primer_recipes(main: FunctionBasedRecipe): | ||
kwargs = {} | ||
for p in signature(main).parameters.values(): | ||
if p.default is not p.empty: | ||
value = p.default | ||
elif issubclass(p.annotation, str): | ||
value = fake.sentence() | ||
elif issubclass(p.annotation, Paper): | ||
value = paper | ||
else: | ||
raise ValueError(f"Cannot handle parameter {p}") | ||
kwargs[p.name] = value | ||
await main(**kwargs) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.