[clang] [libclang/python] Improve test coverage (PR #109846)
Jannick Kremer via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 24 11:52:28 PDT 2024
================
@@ -308,10 +310,10 @@ def test_element_type(self):
def test_invalid_element_type(self):
"""Ensure Type.element_type raises if type doesn't have elements."""
tu = get_tu("int i;")
- i = get_cursor(tu, "i")
- self.assertIsNotNone(i)
- with self.assertRaises(Exception):
- i.element_type
+ ty = get_cursor(tu, "i").type
+ with self.assertRaises(Exception) as ctx:
+ ty.element_type
+ self.assertEqual(str(ctx.exception), "Element type not available on this type.")
----------------
DeinAlptraum wrote:
This test didn't make any sense previously: `i` was of type `Cursor`, so the test raised an `AttributeError` exception due to missing `element_type` attribute.
https://github.com/llvm/llvm-project/pull/109846
More information about the cfe-commits
mailing list