Server : Apache System : Linux indy02.toastserver.com 3.10.0-962.3.2.lve1.5.85.el7.x86_64 #1 SMP Thu Apr 18 15:18:36 UTC 2024 x86_64 User : palandch ( 1163) PHP Version : 7.1.33 Disable Function : NONE Directory : /opt/alt/python27/lib64/python2.7/site-packages/simplejson/tests/ |
from unittest import TestCase import simplejson as json class TestErrors(TestCase): def test_string_keys_error(self): data = [{'a': 'A', 'b': (2, 4), 'c': 3.0, ('d',): 'D tuple'}] self.assertRaises(TypeError, json.dumps, data) def test_decode_error(self): err = None try: json.loads('{}\na\nb') except json.JSONDecodeError, e: err = e else: self.fail('Expected JSONDecodeError') self.assertEquals(err.lineno, 2) self.assertEquals(err.colno, 1) self.assertEquals(err.endlineno, 3) self.assertEquals(err.endcolno, 2) def test_scan_error(self): err = None for t in (str, unicode): try: json.loads(t('{"asdf": "')) except json.JSONDecodeError, e: err = e else: self.fail('Expected JSONDecodeError') self.assertEquals(err.lineno, 1) self.assertEquals(err.colno, 9)