diff options
author | Dong-hee Na <donghee.na92@gmail.com> | 2019-08-26 07:04:35 (GMT) |
---|---|---|
committer | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-08-26 07:04:35 (GMT) |
commit | 44cd86bbdddb1f7b05deba2c1986a1e98f992429 (patch) | |
tree | 1dfa931ca1747bd69087765c6a3024d2145087ff /Lib/test/test_json/test_dump.py | |
parent | 6b16d938d6d1ccb443815e20e8812deed274dc09 (diff) | |
download | cpython-44cd86bbdddb1f7b05deba2c1986a1e98f992429.zip cpython-44cd86bbdddb1f7b05deba2c1986a1e98f992429.tar.gz cpython-44cd86bbdddb1f7b05deba2c1986a1e98f992429.tar.bz2 |
bpo-37805: Add tests for json.dump(..., skipkeys=True) (GH-15489)
https://bugs.python.org/issue37805
Automerge-Triggered-By: @methane
Diffstat (limited to 'Lib/test/test_json/test_dump.py')
-rw-r--r-- | Lib/test/test_json/test_dump.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_json/test_dump.py b/Lib/test/test_json/test_dump.py index fd0d86b..13b4002 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), |