test_pyq.py 文件源码

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

项目:pyq 作者: caioariede 项目源码 文件源码
def test_classes_with_specific_method(self):
        matches1 = list(self.m.match('class:not(:has(def))',
                        self.filepath('classes.py')))

        matches2 = list(self.m.match('class:has(def[name=bar])',
                        self.filepath('classes.py')))

        matches3 = list(self.m.match('class:has(> def)',
                        self.filepath('classes.py')))

        self.assertEqual(len(matches1), 1)
        self.assertIsInstance(matches1[0][0], ast.ClassDef)

        self.assertEqual(len(matches2), 3)
        self.assertIsInstance(matches2[0][0], ast.ClassDef)
        self.assertIsInstance(matches2[1][0], ast.ClassDef)
        self.assertIsInstance(matches2[2][0], ast.ClassDef)

        self.assertEqual(len(matches3), 2)
        self.assertIsInstance(matches3[0][0], ast.ClassDef)
        self.assertIsInstance(matches3[1][0], ast.ClassDef)
        self.assertEqual(matches3[0][1], 1)
        self.assertEqual(matches3[1][1], 14)
评论列表


问题


面经


文章

微信
公众号

扫码关注公众号