bpo-37805: Add tests for json.dump(..., skipkeys=True) (GH-15489)

https://bugs.python.org/issue37805



Automerge-Triggered-By: @methane
This commit is contained in:
Dong-hee Na 2019-08-26 16:04:35 +09:00 committed by Miss Islington (bot)
parent 6b16d938d6
commit 44cd86bbdd
2 changed files with 11 additions and 0 deletions

View File

@ -12,6 +12,16 @@ class TestDump:
def test_dumps(self):
self.assertEqual(self.dumps({}), '{}')
def test_dump_skipkeys(self):
v = {b'invalid_key': False, 'valid_key': True}
with self.assertRaises(TypeError):
self.json.dumps(v)
s = self.json.dumps(v, skipkeys=True)
o = self.json.loads(s)
self.assertIn('valid_key', o)
self.assertNotIn(b'invalid_key', o)
def test_encode_truefalse(self):
self.assertEqual(self.dumps(
{True: False, False: True}, sort_keys=True),

View File

@ -0,0 +1 @@
Add tests for json.dump(..., skipkeys=True). Patch by Dong-hee Na.