[clang] [libclang/python] Refactor enum usage (PR #95608)
Jannick Kremer via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 14 14:33:30 PDT 2024
================
@@ -31,17 +31,9 @@ class TestCursorKind(unittest.TestCase):
def test_from_id(self):
"""Check that kinds can be constructed from valid IDs"""
for enum in self.enums:
- self.assertEqual(enum.from_id(2), enum._kinds[2])
+ self.assertEqual(enum.from_id(2), enum(2))
+ max_value = max([variant.value for variant in enum])
with self.assertRaises(ValueError):
- enum.from_id(len(enum._kinds))
+ enum.from_id(max_value + 1)
with self.assertRaises(ValueError):
enum.from_id(-1)
-
- def test_unique_kinds(self):
- """Check that no kind name has been used multiple times"""
- for enum in self.enums:
- for id in range(len(enum._kinds)):
- try:
- enum.from_id(id).name
- except ValueError:
- pass
----------------
DeinAlptraum wrote:
This test is effectively pointless now, since the enum class errors out as soon as the module is loaded in case there are duplicate enum variants
https://github.com/llvm/llvm-project/pull/95608
More information about the cfe-commits
mailing list