test_transform_visitor.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:SkiRaff 作者: mathiascj 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号