in testsuite/driver/kill_extra_files.py [0:0]
def visit_Call(self, node: ast.AST) -> None:
self.generic_visit(node)
assert isinstance(node, ast.Call)
if isinstance(node.func, ast.Name) and node.func.id == 'test':
assert(len(node.args) == 4)
name_expr, setup, test_fn, args = node.args
if not(isinstance(name_expr, ast.Str)):
return
name = name_expr.s
if name in extra_src_files:
found_tests.add(name)
if isinstance(setup, ast.Name):
if setup.id == 'normal':
# Kill it
self.fixups.append(Fixup(
line=setup.lineno, col=setup.col_offset,
delete=len(setup.id), insert=extras(name)))
else:
# Make a lit
self.fixups.append(Fixup(
line=setup.lineno, col=setup.col_offset,
delete=0,
insert='[' + list_extras(name, setup.col_offset)))
self.fixups.append(Fixup(
line=setup.lineno,
col=setup.col_offset + len(setup.id),
delete=0, insert=']'))
fixed_tests.add(name)
elif isinstance(setup, ast.List):
# Insert into list at start
if not setup.elts:
ins = extras(name) # no need for comma, newline
# Don't try to delete the list because someone
# might have written "[ ]" for some reason
else:
ins = list_extras(name, setup.col_offset)
self.fixups.append(Fixup(
line=setup.lineno, col=setup.col_offset + 1,
delete=0, insert=ins))
fixed_tests.add(name)
else:
assert False # we fixed them all manually already