Fractus-Vorax v1.0.0 — the takeover: sealed CTE brain + ingestion organs + mechanical speech (199 tests, honest floors)
1da7ac7 verified | # tests/test_gates.py | |
| """Gates structurels : torch ne vit que dans fractus_vorax/model/.""" | |
| from pathlib import Path | |
| REPO = Path(__file__).parent.parent | |
| def test_torch_isolated_in_model_dir(): | |
| package = REPO / "fractus_vorax" | |
| offenders = [] | |
| for py in package.rglob("*.py"): | |
| if py.parent == package / "model": | |
| continue # autorisé ici et ici seulement | |
| text = py.read_text(encoding="utf-8") | |
| if "import torch" in text or "from torch" in text: | |
| offenders.append(str(py.relative_to(REPO))) | |
| # imports dynamiques : importlib.import_module("torch"), | |
| # __import__("torch") — même confinement, motif "torch" + appel. | |
| elif "torch" in text and ("import_module" in text or "__import__" in text): | |
| offenders.append(str(py.relative_to(REPO))) | |
| # tokenizers : même confinement que torch (fractus_vorax/model/ seulement). | |
| if "import tokenizers" in text or "from tokenizers" in text: | |
| offenders.append(str(py.relative_to(REPO))) | |
| assert offenders == [] | |
| def test_gate_catches_dynamic_import_patterns(tmp_path): | |
| fake = tmp_path / "fake.py" | |
| fake.write_text('import importlib\nimportlib.import_module("torch")\n', encoding="utf-8") | |
| text = fake.read_text(encoding="utf-8") | |
| assert ("torch" in text and ("import_module" in text or "__import__" in text)) | |