diff options
author | Bob Ippolito <bob@redivi.com> | 2017-11-23 13:36:13 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-23 13:36:13 -0800 |
commit | 9127262d5c5ddc572c298ecd9f99fd426a9e9584 (patch) | |
tree | 047703bb892c670002809b43a5972c9c85e46bc1 /simplejson/tests | |
parent | db043ca417f328f3bfc1ce36ab0ea8bab9f257c5 (diff) | |
parent | 5c57849b24fae8c071cbf62f205046d8120a0c80 (diff) | |
download | simplejson-9127262d5c5ddc572c298ecd9f99fd426a9e9584.tar.gz |
Merge pull request #191 from simplejson/type-error-messages
Make TypeError messages contain type name instead of a repr.
Diffstat (limited to 'simplejson/tests')
-rw-r--r-- | simplejson/tests/test_errors.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/simplejson/tests/test_errors.py b/simplejson/tests/test_errors.py index 8dede38..78f25a5 100644 --- a/simplejson/tests/test_errors.py +++ b/simplejson/tests/test_errors.py @@ -7,7 +7,24 @@ from simplejson.compat import u, b 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) + try: + json.dumps(data) + except TypeError: + err = sys.exc_info()[1] + else: + self.fail('Expected TypeError') + self.assertEqual(str(err), + 'keys must be str, int, float, bool or None, not tuple') + + def test_not_serializable(self): + try: + json.dumps(json) + except TypeError: + err = sys.exc_info()[1] + else: + self.fail('Expected TypeError') + self.assertEqual(str(err), + 'Object of type module is not JSON serializable') def test_decode_error(self): err = None |