================
@@ -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
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to