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)
评论列表
文章目录