The suite takes its data from the vectors and fixtures: 3635 tests, 97.9% branch coverage, and paperspec check and paperspec stress give the same results as before. Fixed: receipts.verify_signature raised KeyError for a record without a format; traces.DOC_TAG matched a tag followed by a line feed; paperspec load and paperspec check left SQLite connections open; the site builder copied the output folder's subfolders into itself. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B8cL4zN4XpaQF5cBtASzfq
42 lines
1.0 KiB
Python
42 lines
1.0 KiB
Python
# 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/<name>.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
|