Author: Armin Rigo <[email protected]>
Branch: py3.5
Changeset: r89639:f11fffc36423
Date: 2017-01-17 17:42 +0000
http://bitbucket.org/pypy/pypy/changeset/f11fffc36423/

Log:    fix or skip remaining tests in json

diff --git a/lib-python/3/test/test_json/test_fail.py 
b/lib-python/3/test/test_json/test_fail.py
--- a/lib-python/3/test/test_json/test_fail.py
+++ b/lib-python/3/test/test_json/test_fail.py
@@ -1,4 +1,5 @@
 from test.test_json import PyTest, CTest
+from test import support
 import re
 
 # 2007-10-05
@@ -127,7 +128,16 @@
             with self.assertRaises(self.JSONDecodeError) as cm:
                 self.loads(data)
             err = cm.exception
-            self.assertEqual(err.msg, msg)
+            if support.check_impl_detail():
+                self.assertEqual(err.msg, msg)
+            else:
+                if data in ['[42',         # skip these tests, PyPy gets
+                            '["spam"',     # another error which makes sense
+                            '{"spam":42',  # too: unterminated array
+                           ]:
+                    continue
+                msg = err.msg   # ignore the message provided in the test,
+                                # only check for position
             self.assertEqual(err.pos, idx)
             self.assertEqual(err.lineno, 1)
             self.assertEqual(err.colno, idx + 1)
@@ -163,7 +173,11 @@
             with self.assertRaises(self.JSONDecodeError) as cm:
                 self.loads(data)
             err = cm.exception
-            self.assertEqual(err.msg, msg)
+            if support.check_impl_detail():
+                self.assertEqual(err.msg, msg)
+            else:
+                msg = err.msg   # ignore the message provided in the test,
+                                # only check for position
             self.assertEqual(err.pos, idx)
             self.assertEqual(err.lineno, 1)
             self.assertEqual(err.colno, idx + 1)
@@ -205,13 +219,18 @@
             with self.assertRaises(self.JSONDecodeError) as cm:
                 self.loads(data)
             err = cm.exception
-            self.assertEqual(err.msg, 'Expecting value')
+            if support.check_impl_detail():
+                msg = 'Expecting value'
+                self.assertEqual(err.msg, msg)
+            else:
+                msg = err.msg   # ignore the message provided in the test,
+                                # only check for position
             self.assertEqual(err.pos, idx)
             self.assertEqual(err.lineno, line)
             self.assertEqual(err.colno, col)
             self.assertEqual(str(err),
-                             'Expecting value: line %s column %d (char %d)' %
-                             (line, col, idx))
+                             '%s: line %s column %d (char %d)' %
+                             (msg, line, col, idx))
 
 class TestPyFail(TestFail, PyTest): pass
 class TestCFail(TestFail, CTest): pass
diff --git a/pypy/module/_pypyjson/interp_decoder.py 
b/pypy/module/_pypyjson/interp_decoder.py
--- a/pypy/module/_pypyjson/interp_decoder.py
+++ b/pypy/module/_pypyjson/interp_decoder.py
@@ -107,9 +107,7 @@
         elif ch.isdigit():
             return self.decode_numeric(i)
         else:
-            raise DecoderError(
-                "No JSON object could be decoded: unexpected '%s' at" % ch,
-                i)
+            raise DecoderError("Unexpected '%s' at" % ch, i)
 
     def decode_null(self, i):
         if (self.ll_chars[i]   == 'u' and
diff --git a/pypy/module/_pypyjson/test/test__pypyjson.py 
b/pypy/module/_pypyjson/test/test__pypyjson.py
--- a/pypy/module/_pypyjson/test/test__pypyjson.py
+++ b/pypy/module/_pypyjson/test/test__pypyjson.py
@@ -218,15 +218,15 @@
     def test_error_position(self):
         import _pypyjson
         test_cases = [
-            ('[,', "No JSON object could be decoded: unexpected ',' at", 1),
-            ('{"spam":[}', "No JSON object could be decoded: unexpected '}' 
at", 9),
+            ('[,', "Unexpected ',' at", 1),
+            ('{"spam":[}', "Unexpected '}' at", 9),
             ('[42:', "Unexpected ':' when decoding array", 3),
             ('[42 "spam"', "Unexpected '\"' when decoding array", 4),
-            ('[42,]', "No JSON object could be decoded: unexpected ']' at", 4),
+            ('[42,]', "Unexpected ']' at", 4),
             ('{"spam":[42}', "Unexpected '}' when decoding array", 11),
             ('["]', 'Unterminated string starting at', 1),
             ('["spam":', "Unexpected ':' when decoding array", 7),
-            ('[{]', "No JSON object could be decoded: unexpected ']' at", 2),
+            ('[{]', "Unexpected ']' at", 2),
         ]
         for inputtext, errmsg, errpos in test_cases:
             exc = raises(ValueError, _pypyjson.loads, inputtext)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to