def test_remove_field():
"""
Tests the removal of an AST node that is referenced by a field of the parent node.
"""
@ast_transformer
def remove_field(node, **kwds):
if isinstance(node, ast.arg) and node.arg == 'x':
return None
else:
return node
node = get_ast(dummy)
new_node = check_mutation(node, remove_field)
assert_ast_equal(new_node, get_ast("""
def dummy(y):
c = 4
a = 1
"""))
# Error checks
评论列表
文章目录