def test_start_ModifyPositionalArg(self):
# Arrange
program = "{}(conn, args)"
transform_visitor = TransformVisitor(self.conn_scope)
for s in MODIFY_LIST:
p = program.format(s)
actual = ast.parse(p)
old = ast.parse(p)
# Act
transform_visitor.start(actual)
# Assert
# We check that some modification has been made
self.assertNotEqual(dump(actual), dump(old))
# We check that the correct change was made
self.assertEqual(actual.body[0].value.args[0].id, 'conn_a')
# We check that nothing else was changed, this is done by removing
# the part that should be changed from both.
actual.body[0].value.args[0] = None
old.body[0].value.args[0] = None
self.assertEqual(dump(actual), dump(old))
评论列表
文章目录