Skip to content

Testing decks

Use fabcheck.testing for offline deck assertions. See validation for reports, errors, and backend support.

Deck assertions

Python
from fabcheck import Deck
from fabcheck.testing import assert_diagnostics, assert_rule_ids, assert_valid

deck = Deck("example", units="um")
metal = deck.layer(10, 0)
deck.rule("M1.WIDTH", "Metal must be at least 0.2 um wide", violations=metal.min_width(0.2))

compiled = assert_valid(deck)
assert_rule_ids(compiled, ["M1.WIDTH"])
assert_diagnostics(deck.validate(), [])
Helper Assertion What it does and why
assert_valid(deck, capabilities=None) Returns a compiled snapshot or raises AssertionError with diagnostics Checks that the deck is valid and returns its compiled snapshot. Use it in a test so invalid authoring produces a readable assertion failure.
assert_rule_ids(compiled, expected) Exact rule IDs in declaration order Compares all rule IDs and their order with the expected list. Use it to catch missing, extra, or reordered rules.
assert_diagnostics(report, expected) Exact diagnostic codes and multiplicity, ignoring order Compares diagnostic codes and counts without requiring a particular order. Use it to test expected errors without tying the test to message wording.
assert_requirements(compiled, expected) Exact operation versions and options, ignoring order Compares the exact operation versions and options needed by the deck. Use it to detect an unintended change in backend requirements.

Pass capabilities=... to assert_valid to check backend support. Builder exceptions propagate before a report exists.

Test geometry in the execution backend with synthetic fixtures for equality, neighboring grid values, empty inputs, hierarchy, and marker types. Check actual geometry, not just finding counts.

Contributing

From a checkout, use Python 3.11 or 3.12:

Bash
uv sync --locked --python 3.12
uv run pytest
uv run mypy
uv run ruff check src tests examples scripts tools/check_artifacts.py
uv run ruff format --check src tests examples scripts tools/check_artifacts.py
uv run python -m fabcheck.style examples
uv build
uv run python tools/check_artifacts.py

CI checks Python 3.11 and 3.12 with locked dependencies and minimum Pydantic. Artifact inspection checks the license, typing marker, dependencies, and package contents. Public examples and fixtures must use synthetic data.