MCPcopy Index your code
hub / github.com/RustPython/RustPython / iter_tests

Function iter_tests

scripts/update_lib/patch_spec.py:206–221  ·  view source on GitHub ↗
(
    tree: ast.Module,
)

Source from the content-addressed store, hash-verified

204
205
206def iter_tests(
207 tree: ast.Module,
208) -> "Iterator[tuple[ast.ClassDef, ast.FunctionDef | ast.AsyncFunctionDef]]":
209 for key, nodes in ast.iter_fields(tree):
210 if key != "body":
211 continue
212
213 for cls_node in nodes:
214 if not isinstance(cls_node, ast.ClassDef):
215 continue
216
217 for fn_node in cls_node.body:
218 if not isinstance(fn_node, (ast.FunctionDef, ast.AsyncFunctionDef)):
219 continue
220
221 yield (cls_node, fn_node)
222
223
224def iter_patches(contents: str) -> "Iterator[PatchEntry]":

Callers 6

extract_test_methodsFunction · 0.90
test_iter_tests_asyncMethod · 0.90
iter_patch_entriesMethod · 0.85
_iter_patch_linesFunction · 0.85

Calls 1

isinstanceFunction · 0.85

Tested by 3

test_iter_tests_asyncMethod · 0.72