73 lines
1.8 KiB
Python
73 lines
1.8 KiB
Python
from __future__ import annotations
|
|||
|
|
|
||
|
|
import json
|
||
|
|
import shutil
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
import pytest
|
||
|
|
|
||
|
|
ROOT = Path(__file__).resolve().parent.parent
|
||
|
|
DIST = ROOT / "boxsim_dl" / "BoxSim 2.1 DE (Stand 12.2025)"
|
||
|
|
DEFAULT_BPJ = DIST / "Projekte" / "Default.BPJ"
|
||
|
|
MANIFEST = ROOT / "tests" / "oracle_manifest.json"
|
||
|
|
|
||
|
|
|
||
|
|
def pytest_configure(config):
|
||
|
|
config.addinivalue_line("markers", "needs_kicad: requires kicad-cli 10 on PATH")
|
||
|
|
config.addinivalue_line("markers", "needs_dist: requires the Boxsim distribution")
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.fixture(scope="session")
|
||
|
|
def dist() -> Path:
|
||
|
|
if not DIST.exists():
|
||
|
|
pytest.skip(f"Boxsim distribution not present at {DIST}")
|
||
|
|
return DIST
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.fixture(scope="session")
|
||
|
|
def default_bpj(dist: Path) -> Path:
|
||
|
|
if not DEFAULT_BPJ.exists():
|
||
|
|
pytest.skip("Default.BPJ not present")
|
||
|
|
return DEFAULT_BPJ
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.fixture(scope="session")
|
||
|
|
def manifest() -> dict:
|
||
|
|
if not MANIFEST.exists():
|
||
|
|
pytest.skip("oracle manifest missing; run tools/difftest.py")
|
||
|
|
return json.loads(MANIFEST.read_text(encoding="utf-8"))
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.fixture(scope="session")
|
||
|
|
def kicad_cli() -> str:
|
||
|
|
exe = shutil.which("kicad-cli")
|
||
|
|
if exe is None:
|
||
|
|
pytest.skip("kicad-cli not on PATH")
|
||
|
|
return exe
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.fixture(scope="session")
|
||
|
|
def library():
|
||
|
|
from boxsim import symbols
|
||
|
|
|
||
|
|
try:
|
||
|
|
return symbols.load()
|
||
|
|
except symbols.SymbolError as exc:
|
||
|
|
pytest.skip(str(exc))
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.fixture(scope="session")
|
||
|
|
def catalog():
|
||
|
|
from boxsim import catalog as catalog_mod
|
||
|
|
|
||
|
|
try:
|
||
|
|
return catalog_mod.load()
|
||
|
|
except catalog_mod.CatalogError as exc:
|
||
|
|
pytest.skip(str(exc))
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.fixture(scope="session")
|
||
|
|
def default_project(default_bpj: Path):
|
||
|
|
from boxsim import model
|
||
|
|
|
||
|
|
return model.load(default_bpj.read_bytes())
|