Author: Jean-Paul Calderone <[email protected]>
Branch: py3.5
Changeset: r92142:e2a71b4f385a
Date: 2017-08-14 08:16 -0400
http://bitbucket.org/pypy/pypy/changeset/e2a71b4f385a/
Log: Replace fragile upstream expat exception test with a more reasonable
one
diff --git a/lib-python/3/test/test_pyexpat.py
b/lib-python/3/test/test_pyexpat.py
--- a/lib-python/3/test/test_pyexpat.py
+++ b/lib-python/3/test/test_pyexpat.py
@@ -11,7 +11,7 @@
from xml.parsers import expat
from xml.parsers.expat import errors
-from test.support import sortdict
+from test.support import sortdict, impl_detail
class SetAttributeTest(unittest.TestCase):
@@ -446,6 +446,7 @@
self.assertEqual(os.path.basename(entry[0]), filename)
self.assertEqual(entry[2], funcname)
+ @impl_detail("PyPy does not have pyexpat.c", pypy=False)
def test_exception(self):
parser = expat.ParserCreate()
parser.StartElementHandler = self.StartElementHandler
@@ -458,6 +459,7 @@
" found %r" % e.args[0])
# Check that the traceback contains the relevant line in pyexpat.c
entries = traceback.extract_tb(e.__traceback__)
+ print(entries)
self.assertEqual(len(entries), 3)
self.check_traceback_entry(entries[0],
"test_pyexpat.py", "test_exception")
diff --git a/pypy/module/pyexpat/test/test_parser.py
b/pypy/module/pyexpat/test/test_parser.py
--- a/pypy/module/pyexpat/test/test_parser.py
+++ b/pypy/module/pyexpat/test/test_parser.py
@@ -210,6 +210,30 @@
p.ParseFile(fake_reader)
assert fake_reader.read_count == 4
+
+ def test_exception(self):
+ """
+ lib-python/3/test_pyexpat.py:HandlerExceptionTest.test_exception port
+ without the fragile traceback inspection.
+ """
+ import pyexpat as expat
+
+ def StartElementHandler(name, attrs):
+ raise RuntimeError(name)
+
+ parser = expat.ParserCreate()
+ parser.StartElementHandler = StartElementHandler
+
+ try:
+ parser.Parse(b"<a><b><c/></b></a>", 1)
+ self.fail()
+ except RuntimeError as e:
+ assert e.args[0] == 'a', (
+ "Expected RuntimeError for element 'a', but" + \
+ " found %r" % e.args[0]
+ )
+
+
class AppTestPyexpat2:
spaceconfig = dict(usemodules=['_rawffi', 'pyexpat', 'itertools',
'_socket', 'time', 'struct', 'binascii',
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit