def test_isPythonException(self): try: a = objc.lookUpClass("NSArray").array() a.objectAtIndex_(42) except Exception as exc: self.assertFalse(Debugging.isPythonException(exc)) else: self.fail("Exception not raised") try: cls = objc.lookUpClass("NSException") cls.exceptionWithName_reason_userInfo_("FooBar", "hello world", None).raise__() except Exception as exc: self.assertFalse(Debugging.isPythonException(exc)) else: self.fail("Exception not raised") try: a = [] a[42] except Exception as exc: self.assertTrue(Debugging.isPythonException(exc))
def test_isPythonException(self): try: a = objc.lookUpClass('NSArray').array() a.objectAtIndex_(42) except Exception as exc: self.assertFalse(Debugging.isPythonException(exc)) try: a = [] a[42] except Exception as exc: self.assertTrue(Debugging.isPythonException(exc))
def testInstallExceptionHandler(self): self.assertFalse(Debugging.handlerInstalled()) try: Debugging.installExceptionHandler( verbosity=Debugging.LOGSTACKTRACE, mask=Debugging.EVERYTHINGMASK) self.assertTrue(Debugging.handlerInstalled()) try: cls = objc.lookUpClass("NSException") cls.exceptionWithName_reason_userInfo_("FooBar", "hello world", None).raise__() except Exception as exc: self.assertFalse(Debugging.isPythonException(exc)) else: self.fail("Exception not raised") try: cls = objc.lookUpClass("NSArray") def test(value, idx, stop): raise ValueError("42") a = cls.alloc().initWithArray_([1, 2, 3, 4]) a.indexOfObjectPassingTest_(test) except Exception as exc: self.assertTrue(Debugging.isPythonException(exc)) else: self.fail("Exception not raised") finally: Debugging.removeExceptionHandler() self.assertFalse(Debugging.handlerInstalled())