chore: Checkpoint commit of unstaged changes, including new tests and debug scripts
This commit is contained in:
44
tests/test_ast_parser_curated.py
Normal file
44
tests/test_ast_parser_curated.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import pytest
|
||||
from file_cache import ASTParser
|
||||
|
||||
def test_ast_parser_get_curated_view():
|
||||
parser = ASTParser("python")
|
||||
code = '''
|
||||
@core_logic
|
||||
def core_func():
|
||||
"""Core logic doc."""
|
||||
print("this should be preserved")
|
||||
return True
|
||||
|
||||
def hot_func():
|
||||
# [HOT]
|
||||
print("this should also be preserved")
|
||||
return 42
|
||||
|
||||
def normal_func():
|
||||
"""Normal doc."""
|
||||
print("this should be stripped")
|
||||
return None
|
||||
|
||||
class MyClass:
|
||||
@core_logic
|
||||
def core_method(self):
|
||||
print("method preserved")
|
||||
'''
|
||||
curated = parser.get_curated_view(code)
|
||||
|
||||
# Check that core_func is preserved
|
||||
assert 'print("this should be preserved")' in curated
|
||||
assert 'return True' in curated
|
||||
|
||||
# Check that hot_func is preserved
|
||||
assert '# [HOT]' in curated
|
||||
assert 'print("this should also be preserved")' in curated
|
||||
|
||||
# Check that normal_func is stripped but docstring is preserved
|
||||
assert '"""Normal doc."""' in curated
|
||||
assert 'print("this should be stripped")' not in curated
|
||||
assert '...' in curated
|
||||
|
||||
# Check that core_method is preserved
|
||||
assert 'print("method preserved")' in curated
|
||||
Reference in New Issue
Block a user