1
0
Fork 0
mirror of https://github.com/evilhero/mylar synced 2025-01-03 13:34:33 +00:00
mylar/lib/simplejson/tests/test_errors.py
Brian Hartvigsen 69eeb9b49d Put libs/ in sys.path
Update bs4 to latest version to fix issues
Get clean modules using `pip install --upgrade --target=lib`
Move cherrypy, mako, pystun, bs4 into lib directory
2016-08-23 00:01:41 -06:00

34 lines
No EOL
1 KiB
Python

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)