Spaces:
Running on T4
Running on T4
Download AI-coach-agent/tests/conftest.py from modventures/baseball-engine: direct link, hf CLI and curl.
- Browser
- Download file 1.76 kB
-
https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/AI-coach-agent/tests/conftest.py
- Command line
-
hf download hf://spaces/modventures/baseball-engine/AI-coach-agent/tests/conftest.py
-
curl -L -o conftest.py https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/AI-coach-agent/tests/conftest.py
1.76 kB
| """Fixtures: settings that never touch the network or the real cache.""" | |
| from __future__ import annotations | |
| import logging | |
| import pytest | |
| from ai_coach.config import Settings | |
| from ai_coach.input_builder import build_coach_input | |
| from ai_coach.schemas import CoachInput | |
| from .helpers import example_names, load_example | |
| def isolate_coach_logging(): | |
| """Entry-point tests must not leave their file handlers or propagation policy behind.""" | |
| logger = logging.getLogger("ai_coach") | |
| handlers = list(logger.handlers) | |
| level, propagate, disabled = logger.level, logger.propagate, logger.disabled | |
| try: | |
| yield | |
| finally: | |
| for handler in list(logger.handlers): | |
| if handler not in handlers: | |
| logger.removeHandler(handler) | |
| handler.close() | |
| for handler in handlers: | |
| if handler not in logger.handlers: | |
| logger.addHandler(handler) | |
| logger.setLevel(level) | |
| logger.propagate, logger.disabled = propagate, disabled | |
| def settings(tmp_path) -> Settings: | |
| """LLM disabled by default; tests that need it pass a key explicitly.""" | |
| return Settings(_env_file=None, google_api_key=None, cache_path=tmp_path / "cache.sqlite3", daily_budget_usd=1.0) | |
| def keyed_settings(tmp_path) -> Settings: | |
| return Settings( | |
| _env_file=None, | |
| google_api_key="test-key-123", | |
| cache_path=tmp_path / "cache.sqlite3", | |
| model="gemini-3.1-flash-lite", | |
| escalation_model="gemini-3.8-flash", | |
| daily_budget_usd=1.0, | |
| ) | |
| def real_inputs() -> dict[str, CoachInput]: | |
| return {name: build_coach_input(load_example(name)) for name in example_names()} | |