[Jython-checkins] jython: Test for a more informative message when a Java StackOverflowError is raised
jim.baker
jython-checkins at python.org
Fri May 23 22:12:07 CEST 2014
http://hg.python.org/jython/rev/b3081e5fad92
changeset: 7276:b3081e5fad92
user: Jim Baker <jim.baker at rackspace.com>
date: Fri May 23 13:54:07 2014 -0600
summary:
Test for a more informative message when a Java StackOverflowError is raised
files:
Lib/test/test_exceptions_jy.py | 15 ++++++++++
tests/java/javatests/StackOverflowErrorTest.java | 12 ++++++++
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_exceptions_jy.py b/Lib/test/test_exceptions_jy.py
--- a/Lib/test/test_exceptions_jy.py
+++ b/Lib/test/test_exceptions_jy.py
@@ -4,6 +4,8 @@
"""
from test import test_support
import unittest
+from javatests import StackOverflowErrorTest
+
class C:
def __str__(self):
@@ -41,6 +43,19 @@
return
unittest.fail("if __str__ raises an exception, re-raise")
+ def test_wrap_StackOverflowError(self):
+ with self.assertRaises(RuntimeError) as cm:
+ StackOverflowErrorTest.throwStackOverflowError()
+ self.assertEqual(
+ cm.exception.message,
+ "maximum recursion depth exceeded (Java StackOverflowError)")
+
+ with self.assertRaises(RuntimeError) as cm:
+ StackOverflowErrorTest.causeStackOverflowError()
+ self.assertEqual(
+ cm.exception.message,
+ "maximum recursion depth exceeded (Java StackOverflowError)")
+
def test_main():
test_support.run_unittest(ExceptionsTestCase)
diff --git a/tests/java/javatests/StackOverflowErrorTest.java b/tests/java/javatests/StackOverflowErrorTest.java
new file mode 100644
--- /dev/null
+++ b/tests/java/javatests/StackOverflowErrorTest.java
@@ -0,0 +1,12 @@
+package javatests;
+
+public class StackOverflowErrorTest {
+
+ public static void throwStackOverflowError() {
+ throw new StackOverflowError();
+ }
+
+ public static void causeStackOverflowError() {
+ causeStackOverflowError();
+ }
+}
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list