Skip to content
This repository was archived by the owner on Jan 13, 2026. It is now read-only.

Commit 845b419

Browse files
committed
Test both BEFORE and AFTER modes
1 parent 0d32702 commit 845b419

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

rewrite/tests/python/all/templating/template_test.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_tree_substitution():
3232
)
3333

3434

35-
def test_add_statement():
35+
def test_add_statement_last():
3636
rewrite_run(
3737
# language=python
3838
python(
@@ -56,6 +56,30 @@ def f():
5656
)
5757

5858

59+
def test_add_statement_first():
60+
rewrite_run(
61+
# language=python
62+
python(
63+
"""\
64+
def f():
65+
return
66+
""",
67+
"""\
68+
def f():
69+
pass
70+
return
71+
"""
72+
),
73+
spec=RecipeSpec()
74+
.with_recipe(from_visitor(
75+
AddLastTemplatingVisitor(
76+
lambda j: isinstance(j, MethodDeclaration) and len(j.body.statements) == 1,
77+
'pass',
78+
coordinate_provider=lambda m: cast(MethodDeclaration, m).body.statements[0].get_coordinates().before())
79+
))
80+
)
81+
82+
5983
def test_tree_substitution_named():
6084
rewrite_run(
6185
# language=python

0 commit comments

Comments
 (0)