summaryrefslogtreecommitdiff
path: root/simplejson/tests
diff options
context:
space:
mode:
authorBob Ippolito <bob@redivi.com>2017-11-23 13:36:13 -0800
committerGitHub <noreply@github.com>2017-11-23 13:36:13 -0800
commit9127262d5c5ddc572c298ecd9f99fd426a9e9584 (patch)
tree047703bb892c670002809b43a5972c9c85e46bc1 /simplejson/tests
parentdb043ca417f328f3bfc1ce36ab0ea8bab9f257c5 (diff)
parent5c57849b24fae8c071cbf62f205046d8120a0c80 (diff)
downloadsimplejson-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.py19
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