Files
015-coffee-machine/tests/conftest.py
T
Tirsvad 8a0e03a6ff Add tests and publish repository metadata for MIL-003
Add 19 pytest tests covering the report, resource check, coin
processing, refunds, change, profit, make_coffee and the main loop.
Add a tests package and put the project root on the pytest path.
Doxygen output is clean. The repository description and topics were set
on the git host.

Closes #13
Closes #14
Closes #15
Closes #16
Closes #17

Task: MIL-003#1
Task: MIL-003#2
Task: MIL-003#3
Task: MIL-003#4
Task: MIL-003#5
2026-10-06 19:56:08 +08:00

26 lines
640 B
Python

"""!
@file conftest.py
@brief Shared pytest helpers.
"""
from collections.abc import Callable, Iterable
import pytest
ScriptInput = Callable[[Iterable[str]], None]
@pytest.fixture
def script_input(monkeypatch: pytest.MonkeyPatch) -> ScriptInput:
"""!
@brief Provide a function that feeds the given answers to `input`.
@param monkeypatch pytest's monkeypatch fixture.
@return A function taking the answers in the order they are asked.
"""
def feed(answers: Iterable[str]) -> None:
remaining = iter(answers)
monkeypatch.setattr("builtins.input", lambda _prompt: next(remaining))
return feed