def test_start_ModifyKeywordArg(self):
# Arrange
program = "{}(connection=conn, args=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.keywords[0].value.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.keywords[0].value = None
old.body[0].value.keywords[0].value = None
self.assertEqual(dump(actual), dump(old))
评论列表
文章目录