def testThrowChildExceptionFromCatchJExceptionParentClass(self) : try : self.jpype.exc.ExceptionTest.throwChildTestException() assert False except JException(self.jpype.exc.ParentTestException), ex : pyexc = self.jpype.exc.ChildTestException.PYEXC assert isinstance(ex, pyexc)
def testExceptionByJavaClass(self) : try : self.jpype.exc.ExceptionTest.throwRuntime() assert False except JException(java.lang.RuntimeException), ex : print "Caught the exception", ex.message(), "->", ex.javaClass() print ex.stacktrace()
def testExceptionByJavaClass(self): try: self.jpype.exc.ExceptionTest.throwRuntime() self.fail() # pragma: no cover # <AK> added except JException(java.lang.RuntimeException) as ex: self.assertIs(ex.javaClass(), java.lang.RuntimeException) self.assertEqual('Foo', ex.message()) trace = ex.stacktrace() self.assertTrue(trace.startswith('java.lang.RuntimeException: Foo'))
def testExceptionByJavaClass(self): try: self.jpype.exc.ExceptionTest.throwRuntime() self.fail() except JException(java.lang.RuntimeException) as ex: self.assertIs(type(ex), java.lang.RuntimeException) self.assertEqual('Foo', ex.message()) trace = ex.stacktrace() self.assertTrue(str(trace).startswith( 'java.lang.RuntimeException: Foo'))
def testExceptionByJavaClass(self): try: self.jpype.exc.ExceptionTest.throwRuntime() assert False except JException(java.lang.RuntimeException) as ex: print(("Caught the exception {0} -> {1}".format( ex.message(), ex.javaClass()))) print(ex.stacktrace()) except Exception as ex: print(ex) assert False
def testThrowChildExceptionFromCatchJExceptionParentClass(self): try: self.jpype.exc.ExceptionTest.throwChildTestException() self.fail() except JException(self.jpype.exc.ParentTestException) as ex: self.assertIsInstance(ex, self.jpype.exc.ChildTestException)
def testThrowChildExceptionFromCatchJExceptionParentClass(self): try: self.jpype.exc.ExceptionTest.throwChildTestException() self.fail() # pragma: no cover # <AK> added except JException(self.jpype.exc.ParentTestException) as ex: self.assertIsInstance(ex, self.jpype.exc.ChildTestException.PYEXC)