Files
manual_slop/tests/test_tree_sitter_setup.py
T
ed b5e512f483 feat(sdm): inject structural dependency mapping tags across codebase
Adds [C: caller] tags to functions/methods and [M: mutation] / [U: usage] tags to class variables based on cross-module call analysis.
2026-05-13 22:35:52 -04:00

27 lines
865 B
Python

import tree_sitter_python as tspython
from tree_sitter import Language, Parser
def test_tree_sitter_python_setup() -> None:
"""
Verifies that tree-sitter and tree-sitter-python are correctly installed
and can parse a simple Python function string.
"""
# Initialize the Python language and parser
PY_LANGUAGE = Language(tspython.language())
parser = Parser(PY_LANGUAGE)
# Simple Python code to parse
code = """def hello():
print('world')"""
# Parse the code
tree = parser.parse(bytes(code, "utf8"))
# Assert that the root node is a 'module'
assert tree.root_node.type == "module"
# Verify we can find a function definition
found_function = False
for child in tree.root_node.children:
if child.type == "function_definition":
found_function = True
break
assert found_function, "Should have found a function_definition node"