Test Fixtures

Shared pytest fixtures and discovery helpers used by the contract suite.

Warning

Pre-implementation. This page describes proposed contracts. Class signatures, parameter types, config field names, and behavior are subject to change before code lands. Once implementation exists, content here will be regenerated from docstrings or sourced from running tests.

Shared fixtures (tests/conftest.py)

import pytest
import torch
import numpy as np
from rfgen.core.rng import _make_generator

@pytest.fixture
def fixed_rng():
    """Deterministic RNG seeded to 42. Use for any test that draws randomness."""
    return _make_generator(seed=42)

@pytest.fixture
def tiny_scene():
    """1 ms × 10 Msps single-RX scene; minimal valid SceneMeta."""
    from rfgen.core.types import SceneMeta
    return SceneMeta(
        sample_rate=10e6,
        duration_s=1e-3,
        bandwidth_hz=10e6,
        center_hz=2.45e9,
        num_emitters=1,
        num_rx=1,
        rx_geometry="single",
        seed=42,
        preset=None,
    )

@pytest.fixture
def tmp_zarr_store(tmp_path):
    """Empty Zarr store at a tmp path; cleaned up after test."""
    from rfgen.storage.zarr_store import ZarrStore
    store = ZarrStore()
    handle = store.open(str(tmp_path / "test.zarr"), mode="w")
    yield handle
    handle.close()

@pytest.fixture
def mock_inference_client(monkeypatch):
    """Drop-in BaseInferenceClient that returns canned JSON responses from fixtures/mock_inference_responses.json."""
    from tests.fixtures.mock_inference import MockInferenceClient
    return MockInferenceClient.from_fixture("mock_inference_responses.json")

See Also