def test_invalid(self): the_ir = get_func_ir(lift_invalid) with self.assertRaises(errors.CompilerError) as raises: with_lifting( the_ir, self.typingctx, self.targetctx, self.flags, locals={}, ) self.assertIn( "Unsupported context manager in use", str(raises.exception), )
def test_undefined_global(self): the_ir = get_func_ir(lift_undefiend) with self.assertRaises(errors.CompilerError) as raises: with_lifting( the_ir, self.typingctx, self.targetctx, self.flags, locals={}, ) self.assertIn( "Undefined variable used as context manager", str(raises.exception), )
def check_extracted_with(self, func, expect_count, expected_stdout): the_ir = get_func_ir(func) new_ir, extracted = with_lifting( the_ir, self.typingctx, self.targetctx, self.flags, locals={}, ) self.assertEqual(len(extracted), expect_count) cres = self.compile_ir(new_ir) with captured_stdout() as out: cres.entry_point() self.assertEqual(out.getvalue(), expected_stdout)