| 204 | |
| 205 | |
| 206 | def 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 | |
| 224 | def iter_patches(contents: str) -> "Iterator[PatchEntry]": |