| 117 | assert isinstance(m.body[3], ast.Expr) |
| 118 | |
| 119 | def test_location_is_set(self) -> None: |
| 120 | s = textwrap.dedent( |
| 121 | """ |
| 122 | |
| 123 | assert False, ( |
| 124 | |
| 125 | "Ouch" |
| 126 | ) |
| 127 | |
| 128 | """ |
| 129 | ) |
| 130 | m = rewrite(s) |
| 131 | for node in m.body: |
| 132 | if isinstance(node, ast.Import): |
| 133 | continue |
| 134 | for n in [node, *ast.iter_child_nodes(node)]: |
| 135 | assert isinstance(n, ast.stmt | ast.expr) |
| 136 | for location in [ |
| 137 | (n.lineno, n.col_offset), |
| 138 | (n.end_lineno, n.end_col_offset), |
| 139 | ]: |
| 140 | assert (3, 0) <= location <= (6, 3) |
| 141 | |
| 142 | def test_positions_are_preserved(self) -> None: |
| 143 | """Ensure AST positions are preserved during rewriting (#12818).""" |