diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 00000000..d930cd50 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +testpaths = src/tests diff --git a/src/recipes/banana_pudding.py b/src/recipes/banana_pudding.py index 793c0035..f1e6dd8a 100644 --- a/src/recipes/banana_pudding.py +++ b/src/recipes/banana_pudding.py @@ -1 +1,13 @@ -obj['code'] +"""Minimal banana pudding recipe model used by the test suite.""" + +from __future__ import annotations + + +class BananaPudding: + """Simple container for banana pudding ingredients.""" + + def __init__(self) -> None: + self.ingredients: list[dict[str, object]] = [] + + def add_ingredient(self, name: str, amount: object) -> None: + self.ingredients.append({"name": name, "amount": amount}) diff --git a/src/tests/conftest.py b/src/tests/conftest.py new file mode 100644 index 00000000..56a01d80 --- /dev/null +++ b/src/tests/conftest.py @@ -0,0 +1,16 @@ +"""Test bootstrap for the src-based modules. + +Pytest runs from the repository root, so add ``src/`` to ``sys.path`` once for +the test session instead of relying on an ad hoc environment variable. +""" + +from __future__ import annotations + +import sys +from pathlib import Path + + +SRC_DIR = Path(__file__).resolve().parents[1] +src_path = str(SRC_DIR) +if src_path not in sys.path: + sys.path.insert(0, src_path)