diff --git a/tests/test_synthetic_fixtures.py b/tests/test_synthetic_fixtures.py index dc8375a..9feea87 100644 --- a/tests/test_synthetic_fixtures.py +++ b/tests/test_synthetic_fixtures.py @@ -7,7 +7,6 @@ import shutil import sqlite3 import struct -import sys import zipfile from pathlib import Path @@ -148,18 +147,22 @@ def test_public_fixture_is_synthetic_sealed_and_exactly_bound( def _is_the_reference_builder() -> bool: """Report whether this interpreter regenerates the committed bytes exactly. - Python 3.12 with the required SQLite and SQLAlchemy is the one environment - that `test_public_fixtures_match_the_source_generator_byte_for_byte` proves - reproduces every committed byte. A tamper test is only meaningful there: on - any other builder a raised `generated bytes are stale` could report the - builder rather than the tamper. + The determinants are the ones the provenance `builder` block names: this + repository's writer code plus the required SQLite and SQLAlchemy versions. + The Python version is not among them. CPython 3.10.20, 3.11.15 and 3.12.13, + each carrying SQLite 3.53.1 and SQLAlchemy 2.0.52, regenerate all ten + committed artifacts identically, so every lane whose libraries match runs + the byte check and the tamper tests rather than skipping them. + + A tamper test is meaningful only on a matching builder: elsewhere a raised + `generated bytes are stale` could report the builder rather than the tamper. """ import sqlalchemy - return sys.version_info[:2] == (3, 12) and ( - sqlite3.sqlite_version, - sqlalchemy.__version__, - ) == (REQUIRED_SQLITE_VERSION, REQUIRED_SQLALCHEMY_VERSION) + return (sqlite3.sqlite_version, sqlalchemy.__version__) == ( + REQUIRED_SQLITE_VERSION, + REQUIRED_SQLALCHEMY_VERSION, + ) REFERENCE_BUILDER_ONLY = pytest.mark.skipif( @@ -175,24 +178,26 @@ def _copy_committed_fixtures(destination: Path) -> Path: def test_public_fixtures_match_the_source_generator_byte_for_byte() -> None: - import sqlalchemy + """Every lane asserts one of the two outcomes, and none asserts nothing. - if sys.version_info[:2] != (3, 12): - actual = (sqlite3.sqlite_version, sqlalchemy.__version__) - expected = (REQUIRED_SQLITE_VERSION, REQUIRED_SQLALCHEMY_VERSION) - if actual != expected: - with pytest.raises(RuntimeError, match="synthetic capture generation requires"): - check_generated( - spec_root=CAPTURE_ROOT / "specs", - output_root=CAPTURE_ROOT, - generator_path=GENERATOR, - ) + A matching builder regenerates the committed bytes and compares them. A + non-matching builder cannot reproduce them, so it asserts that the + generator refuses to write instead of emitting bytes it cannot certify. + """ + if _is_the_reference_builder(): + check_generated( + spec_root=CAPTURE_ROOT / "specs", + output_root=CAPTURE_ROOT, + generator_path=GENERATOR, + ) return - check_generated( - spec_root=CAPTURE_ROOT / "specs", - output_root=CAPTURE_ROOT, - generator_path=GENERATOR, - ) + + with pytest.raises(RuntimeError, match="synthetic capture generation requires"): + check_generated( + spec_root=CAPTURE_ROOT / "specs", + output_root=CAPTURE_ROOT, + generator_path=GENERATOR, + ) @REFERENCE_BUILDER_ONLY