# SPDX-License-Identifier: Apache-2.0 # Copyright 2026 Scienting # # Source Code: https://git.scient.ing/papers/paperspec # See the LICENSE.md file for full license terms. """Shared test helpers. The repository's own vectors and fixtures are the test data: the vectors hold the exact outputs the specification requires, and `fixtures/` holds the packages and records the checks read. """ import json from pathlib import Path import pytest ROOT = Path(__file__).resolve().parent.parent VECTORS = ROOT / "vectors" FIXTURES = ROOT / "fixtures" def read_jsonl(path: Path) -> list[dict]: """Parse a JSON Lines file into a list of records.""" return [ json.loads(line) for line in path.read_text(encoding="utf-8").splitlines() if line ] def vector_cases(name: str) -> list[dict]: """The cases of `vectors/.jsonl`.""" return read_jsonl(VECTORS / f"{name}.jsonl") @pytest.fixture(scope="session") def root() -> Path: """The repository root, where `paperspec check` and `paperspec build` work.""" return ROOT