pheon/tests/python/test_loader.py
Jan Petykiewicz b3346b40a4 Introduce Pheon GDSII parsing and layout review tools
Implement native GDSII reading and writing with Arrow interchange, hierarchy
scans and selective cell loading. Validate numeric packing and array pitches,
and preserve normalized REAL8 encodings exactly within the supported range.

Add standalone dump, structural diff, hierarchy, layer-name annotation and Git
diff commands. Provide scoped text and JSON reports, deterministic comparison,
and record-preserving metadata edits.

Package the shared library and optional Python Arrow readers as pheon using
CFFI ABI mode and Python-independent platform wheels. Include locked source
builds, native API checks, cross-platform artifact workflows, documentation
and regression coverage. Require Rust 1.88 or newer and Python 3.11 or newer.

Validation: 87 native tests, 14 binding tests on Python 3.11/3.13/3.14,
and 71 installed companion integration tests pass. Full, scanned and selected
Arrow layouts match the previous schemas.
2026-11-16 16:21:21 -08:00

36 lines
1.2 KiB
Python

"""Reject incompatible native libraries before exposing callable functions."""
from pathlib import Path
import runpy
from types import SimpleNamespace
import unittest
from unittest.mock import patch
import pheon._native
class LoaderTests(unittest.TestCase):
def load(self, library):
with patch("cffi.FFI.dlopen", return_value=library):
return runpy.run_path(str(Path(pheon._native.__file__)))
def test_matching_versions_are_accepted(self):
self.load(
SimpleNamespace(
pheon_abi_version=lambda: 1, pheon_arrow_schema_version=lambda: 1
)
)
def test_incompatible_abi_or_schema_is_rejected(self):
for abi, schema in [(2, 1), (1, 2)]:
with self.assertRaisesRegex(ImportError, "Incompatible Pheon library"):
self.load(
SimpleNamespace(
pheon_abi_version=lambda: abi,
pheon_arrow_schema_version=lambda: schema,
)
)
def test_unversioned_library_is_rejected(self):
with self.assertRaisesRegex(ImportError, "version API"):
self.load(SimpleNamespace())