40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
import pytest
|
|
from scripts.mma_exec import generate_skeleton
|
|
|
|
def test_generate_skeleton():
|
|
sample_code = '''
|
|
class Calculator:
|
|
"""Performs basic math operations."""
|
|
|
|
def add(self, a: int, b: int) -> int:
|
|
"""Adds two numbers."""
|
|
result = a + b
|
|
return result
|
|
|
|
def log_message(msg):
|
|
timestamp = "2026-02-25"
|
|
print(f"[{timestamp}] {msg}")
|
|
'''
|
|
|
|
skeleton = generate_skeleton(sample_code)
|
|
|
|
# Check that signatures are preserved
|
|
assert "class Calculator:" in skeleton
|
|
assert "def add(self, a: int, b: int) -> int:" in skeleton
|
|
assert "def log_message(msg):" in skeleton
|
|
|
|
# Check that docstrings are preserved
|
|
assert '"""Performs basic math operations."""' in skeleton
|
|
assert '"""Adds two numbers."""' in skeleton
|
|
|
|
# Check that implementation details are removed
|
|
assert "result = a + b" not in skeleton
|
|
assert "return result" not in skeleton
|
|
assert "timestamp =" not in skeleton
|
|
assert "print(" not in skeleton
|
|
|
|
# Check that bodies are replaced with ellipsis
|
|
assert "..." in skeleton
|
|
|
|
if __name__ == "__main__":
|
|
pytest.main([__file__]) |