checkpoint: massive refactor
This commit is contained in:
@@ -2,29 +2,24 @@ import tree_sitter_python as tspython
|
||||
from tree_sitter import Language, Parser
|
||||
|
||||
def test_tree_sitter_python_setup():
|
||||
"""
|
||||
"""
|
||||
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():
|
||||
# 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"
|
||||
# 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"
|
||||
|
||||
Reference in New Issue
Block a user