mirror of
https://github.com/elder-plinius/OBLITERATUS.git
synced 2026-12-05 18:44:41 +01:00
(cherry picked from commit 261d65333d29e1f78e530e74ac091547832c46d0) Adapted for upstream: omitted the 0.1.3 -> 0.2.0 version bumps in obliteratus/__init__.py, pyproject.toml, and the uv.lock version line; this commit keeps test additions only (subject renamed accordingly). The test_checkpoint_inspection.py tweak is kept as a test addition: it reads __version__ dynamically so it passes at 0.1.3. No added test failed on upstream (474 passed across the ten touched files), so nothing was dropped.
73 lines
2.0 KiB
Python
73 lines
2.0 KiB
Python
"""Contracts for every documented lazy package export."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import subprocess
|
|
import sys
|
|
|
|
import pytest
|
|
|
|
import obliteratus
|
|
import obliteratus.analysis as analysis
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"name",
|
|
[
|
|
"AbliterationPipeline",
|
|
"InformedAbliterationPipeline",
|
|
"save_contribution",
|
|
"load_contributions",
|
|
"aggregate_results",
|
|
"TourneyRunner",
|
|
"TourneyResult",
|
|
"get_adaptive_recommendation",
|
|
"AdaptiveRecommendation",
|
|
"RemoteRunner",
|
|
"RemoteConfig",
|
|
"Watchtower",
|
|
"get_watchtower",
|
|
"AutoObliterator",
|
|
"RunArchive",
|
|
"CheckpointService",
|
|
],
|
|
)
|
|
def test_documented_lazy_export_resolves(name):
|
|
assert getattr(obliteratus, name) is not None
|
|
|
|
|
|
def test_unknown_lazy_export_raises_attribute_error():
|
|
with pytest.raises(AttributeError, match="has no attribute 'not_an_export'"):
|
|
getattr(obliteratus, "not_an_export")
|
|
|
|
|
|
def test_analysis_export_map_covers_the_documented_surface():
|
|
assert set(analysis._LAZY_IMPORTS) == set(analysis.__all__)
|
|
assert analysis.CrossLayerAlignmentAnalyzer.__name__ == "CrossLayerAlignmentAnalyzer"
|
|
assert "CrossLayerAlignmentAnalyzer" in dir(analysis)
|
|
|
|
|
|
def test_unknown_analysis_export_raises_attribute_error():
|
|
with pytest.raises(AttributeError, match="has no attribute 'not_an_export'"):
|
|
getattr(analysis, "not_an_export")
|
|
|
|
|
|
def test_importing_analysis_package_does_not_eagerly_import_torch():
|
|
probe = subprocess.run(
|
|
[
|
|
sys.executable,
|
|
"-c",
|
|
(
|
|
"import sys; import obliteratus.analysis as analysis; "
|
|
"assert 'torch' not in sys.modules; "
|
|
"assert not any(name.startswith('obliteratus.analysis.') "
|
|
"for name in sys.modules); "
|
|
"assert analysis.__all__"
|
|
),
|
|
],
|
|
check=False,
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
assert probe.returncode == 0, probe.stderr
|