"""Shared test setup. Puts the repo root on sys.path so `import isr`, `import web` and `import isrweb.*` work regardless of where pytest is invoked from. This used to be an inline sys.path.insert at the top of test_isr.py, which only happened to work for the other test modules because that file imported first. """ import os import sys import wave import pytest sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) @pytest.fixture def write_wav(): """Factory for small 16-bit WAV files. Returns the path written.""" def _write(path, seconds=2, framerate=8000, channels=1, sampwidth=2, frames=None): with wave.open(str(path), 'wb') as wf: wf.setnchannels(channels) wf.setsampwidth(sampwidth) wf.setframerate(framerate) wf.writeframes(frames if frames is not None else b'\x00\x00' * (seconds * framerate * channels)) return path return _write