20 lines
605 B
Python
20 lines
605 B
Python
"""Shared test helpers for Fenris test suite."""
|
|
from pathlib import Path
|
|
|
|
|
|
REPO_ROOT = Path(__file__).resolve().parent.parent
|
|
VERSION_FILE = REPO_ROOT / "pyproject.toml"
|
|
|
|
|
|
def get_version() -> str:
|
|
"""Extract version from pyproject.toml."""
|
|
for line in VERSION_FILE.read_text().splitlines():
|
|
if line.startswith("version"):
|
|
return line.split("=")[1].strip().strip('"')
|
|
raise RuntimeError("Could not determine version from pyproject.toml")
|
|
|
|
|
|
def read(path: str | Path) -> str:
|
|
"""Read a file relative to the repository root."""
|
|
return (REPO_ROOT / path).read_text()
|