mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
bpo-24641: Improved error message for JSON unserializible keys. (#4364)
Also updated an example for default() in the module docstring. Removed quotes around type name in other error messages.
This commit is contained in:
parent
5b48dc638b
commit
cfa797c068
4 changed files with 19 additions and 13 deletions
|
@ -93,12 +93,15 @@ class TestFail:
|
|||
|
||||
def test_non_string_keys_dict(self):
|
||||
data = {'a' : 1, (1, 2) : 2}
|
||||
with self.assertRaisesRegex(TypeError,
|
||||
'keys must be str, int, float, bool or None, not tuple'):
|
||||
self.dumps(data)
|
||||
|
||||
#This is for c encoder
|
||||
self.assertRaises(TypeError, self.dumps, data)
|
||||
|
||||
#This is for python encoder
|
||||
self.assertRaises(TypeError, self.dumps, data, indent=True)
|
||||
def test_not_serializable(self):
|
||||
import sys
|
||||
with self.assertRaisesRegex(TypeError,
|
||||
'Object of type module is not JSON serializable'):
|
||||
self.dumps(sys)
|
||||
|
||||
def test_truncated_input(self):
|
||||
test_cases = [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue