[clang] [libclang/python] Improve test coverage (PR #109846)
Jannick Kremer via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 24 14:16:45 PDT 2024
================
@@ -46,6 +46,8 @@ def test_diagnostic_fixit(self):
self.assertEqual(tu.diagnostics[0].location.column, 26)
self.assertRegex(tu.diagnostics[0].spelling, "use of GNU old-style.*")
self.assertEqual(len(tu.diagnostics[0].fixits), 1)
+ with self.assertRaises(IndexError):
----------------
DeinAlptraum wrote:
This is fairly standard Python and the recommended way to use the `assertRaises` functionality. There's also the older method working like `self.assertRaises(exception_type, function_that_raises, function_arguments)`
`with` keyword starts a context manager. This is most typically used for handling resources that must be explicitly closed, e.g. file handling. In this case specifically, the exception may go off anywhere in that indented `with` block for the test to pass.
https://github.com/llvm/llvm-project/pull/109846
More information about the cfe-commits
mailing list