scripts/tests/proof_generator/test_main_single_commit.py
scripts/tests/proof_generator/test_main_single_commit.pyBrowse 41 files
540 tokens
2,167 bytes
Token encoding: o200k_base
Snapshot a9fb1c3
← Back to SKILL.md
1import sys2from pathlib import Path3 4import pytest5 6sys.path.insert(0, str(Path(__file__).resolve().parents[2]))7 8from generator_testlib import _commit, _write # noqa: F4019from mechanical_refactor_proof_generator import _main10 11 12def _extract_function_commit(repo: Path) -> str:13 _write(14 repo,15 **{16 "kv.py": (17 "class C:\n"18 " def dispatch(self, n):\n"19 " x = self.a\n"20 " y = x + n\n"21 " return y\n"22 "\n"23 " def keep(self):\n"24 " return 0\n"25 )26 },27 )28 _commit(repo, "base")29 _write(30 repo,31 **{32 "kv.py": (33 "class C:\n"34 " def dispatch(self, n):\n"35 " y = self._combine(n=n)\n"36 " return y\n"37 "\n"38 " def _combine(self, *, n):\n"39 " x = self.a\n"40 " y = x + n\n"41 " return y\n"42 "\n"43 " def keep(self):\n"44 " return 0\n"45 )46 },47 )48 return _commit(repo, "extract _combine from dispatch")49 50 51def test_single_commit_extract_function_reproduces_instead_of_unsupported(52 repo: Path, monkeypatch: pytest.MonkeyPatch53) -> None:54 """A pure intra-file extract_function commit run in single-commit mode reproduces (exit 0),55 not UNSUPPORTED -- the relocates check must count extract_functions like the range path.56 """57 sha = _extract_function_commit(repo)58 monkeypatch.chdir(repo)59 assert _main([sha]) == 060 61 62def test_single_commit_pure_rename_is_unsupported(63 repo: Path, monkeypatch: pytest.MonkeyPatch64) -> None:65 """A commit that relocates no definition (a bare rename) stays UNSUPPORTED with exit 1."""66 _write(repo, **{"m.py": "def foo():\n return 1\n"})67 _commit(repo, "base")68 _write(repo, **{"m.py": "def bar():\n return 1\n"})69 sha = _commit(repo, "rename foo to bar")70 monkeypatch.chdir(repo)71 assert _main([sha]) == 172