Spaces:
Configuration error
Configuration error
File size: 1,081 Bytes
3a2e5f0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | """Shared pytest fixtures and config.
Keeping fixtures here (rather than per-test) is the standard pytest pattern
and makes `pytest --fixtures` discoverable for new contributors.
"""
from __future__ import annotations
from collections.abc import Iterator
from pathlib import Path
import pytest
from captioning.utils.seed import set_global_seed
@pytest.fixture(autouse=True)
def _seed_everything() -> Iterator[None]:
"""Seed all RNGs before each test for deterministic results."""
set_global_seed(42)
yield
@pytest.fixture
def tiny_caption_corpus() -> list[str]:
"""A small, deterministic corpus used by tokenizer tests."""
return [
"[start] a man on a surfboard [end]",
"[start] a dog in the park [end]",
"[start] two children playing with a ball [end]",
"[start] a cat sitting on a chair [end]",
"[start] a man riding a bike on the street [end]",
]
@pytest.fixture
def tmp_artifacts_dir(tmp_path: Path) -> Path:
"""A clean temp dir for save/load round-trip tests."""
return tmp_path / "artifacts"
|