MCPcopy Index your code
hub / github.com/python/cpython / test_node_remove_single

Method test_node_remove_single

Lib/test/test_ast/test_ast.py:3081–3094  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3079 self.assertASTEqual(result_ast, expected_ast)
3080
3081 def test_node_remove_single(self):
3082 code = 'def func(arg) -> SomeType: ...'
3083 expected = 'def func(arg): ...'
3084
3085 # Since `FunctionDef.returns` is defined as a single value, we test
3086 # the `if isinstance(old_value, AST):` branch here.
3087 class SomeTypeRemover(ast.NodeTransformer):
3088 def visit_Name(self, node: ast.Name):
3089 self.generic_visit(node)
3090 if node.id == 'SomeType':
3091 return None
3092 return node
3093
3094 self.assertASTTransformation(SomeTypeRemover, code, expected)
3095
3096 def test_node_remove_from_list(self):
3097 code = """

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected