"""Shared pytest fixtures for the yt-dlp download manager tests.""" from __future__ import annotations import json import sys from pathlib import Path import pytest PROJECT_ROOT = Path(__file__).resolve().parent.parent FIXTURES_DIR = Path(__file__).resolve().parent / "fixtures" # Make both the app package and the bundled i18n library importable, exactly # as main.py does for the real application. sys.path.insert(0, str(PROJECT_ROOT / "lib")) sys.path.insert(0, str(PROJECT_ROOT)) from i18n import I18n # noqa: E402 @pytest.fixture(scope="session", autouse=True) def i18n_singleton() -> I18n: """Configure the process-wide I18n singleton once for the whole run. Mirrors what main.py does before starting the real application. """ return I18n( default_language="en", available_languages={"en": "English", "de": "Deutsch"}, project_root=PROJECT_ROOT, ) @pytest.fixture def split_format_json() -> dict: """The "separate audio/video parts" example from the requirements doc.""" with (FIXTURES_DIR / "example_split.json").open(encoding="utf-8") as fh: return json.load(fh) @pytest.fixture def combined_format_json() -> dict: """The "audio+video in one part" example from the requirements doc.""" with (FIXTURES_DIR / "example_combined.json").open(encoding="utf-8") as fh: return json.load(fh)