# -*- coding: utf-8 -*- """ Pytest-Konfiguration und gemeinsame Fixtures. """ import asyncio import sys import tempfile from pathlib import Path from typing import Generator, AsyncGenerator import pytest # Projekt-Pfad hinzufügen sys.path.insert(0, str(Path(__file__).parent.parent)) @pytest.fixture(scope="session") def event_loop(): """Erstellt einen Event-Loop für die gesamte Test-Session.""" loop = asyncio.new_event_loop() yield loop loop.close() @pytest.fixture def temp_dir() -> Generator[Path, None, None]: """Erstellt ein temporäres Verzeichnis für Tests.""" with tempfile.TemporaryDirectory() as tmpdir: yield Path(tmpdir) @pytest.fixture def temp_config_file(temp_dir: Path) -> Path: """Erstellt eine temporäre Konfigurationsdatei.""" config_path = temp_dir / "test_config.json" config_path.write_text('{"test": "value", "number": 42}') return config_path @pytest.fixture def sample_audio_data() -> bytes: """Erstellt Beispiel-Audiodaten.""" # 1 Sekunde Stille bei 16kHz, 16-bit mono return b"\x00\x00" * 16000