From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 26 Aug 2019 07:27:31 +0000 (-0700) Subject: bpo-37805: Add tests for json.dump(..., skipkeys=True) (GH-15489) X-Git-Tag: v3.8.0b4~38 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a3875171d746f90f49adfcaa015525b20a3874d3;p=python bpo-37805: Add tests for json.dump(..., skipkeys=True) (GH-15489) https://bugs.python.org/issue37805 Automerge-Triggered-By: @methane (cherry picked from commit 44cd86bbdddb1f7b05deba2c1986a1e98f992429) Co-authored-by: Dong-hee Na --- diff --git a/Lib/test/test_json/test_dump.py b/Lib/test/test_json/test_dump.py index fd0d86b392..13b4002078 100644 --- a/Lib/test/test_json/test_dump.py +++ b/Lib/test/test_json/test_dump.py @@ -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), diff --git a/Misc/NEWS.d/next/Tests/2019-08-25-19-51-46.bpo-37805.Kl1sti.rst b/Misc/NEWS.d/next/Tests/2019-08-25-19-51-46.bpo-37805.Kl1sti.rst new file mode 100644 index 0000000000..478c38c3d4 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2019-08-25-19-51-46.bpo-37805.Kl1sti.rst @@ -0,0 +1 @@ +Add tests for json.dump(..., skipkeys=True). Patch by Dong-hee Na.