diff options
author | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2010-11-30 03:03:30 +0000 |
---|---|---|
committer | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2010-11-30 03:03:30 +0000 |
commit | ff27ee0b400030419cfd3c9966f275bfbcb569f8 (patch) | |
tree | c2e45325768bd5256432667c387f304d549493e6 /Lib/test/json_tests/test_dump.py | |
parent | 69b34bfe9c3e5da1d7336a607ab56f1c3a178dca (diff) | |
download | cpython-ff27ee0b400030419cfd3c9966f275bfbcb569f8.tar.gz cpython-ff27ee0b400030419cfd3c9966f275bfbcb569f8.zip |
Issue #10572: Moved json tests to Lib/test/json_tests.
Approved by Raymond Hettinger.
Diffstat (limited to 'Lib/test/json_tests/test_dump.py')
-rw-r--r-- | Lib/test/json_tests/test_dump.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/json_tests/test_dump.py b/Lib/test/json_tests/test_dump.py new file mode 100644 index 00000000000..8df234b819c --- /dev/null +++ b/Lib/test/json_tests/test_dump.py @@ -0,0 +1,21 @@ +from unittest import TestCase +from io import StringIO + +import json + +class TestDump(TestCase): + def test_dump(self): + sio = StringIO() + json.dump({}, sio) + self.assertEqual(sio.getvalue(), '{}') + + def test_dumps(self): + self.assertEqual(json.dumps({}), '{}') + + def test_encode_truefalse(self): + self.assertEqual(json.dumps( + {True: False, False: True}, sort_keys=True), + '{"false": true, "true": false}') + self.assertEqual(json.dumps( + {2: 3.0, 4.0: 5, False: 1, 6: True}, sort_keys=True), + '{"false": 1, "2": 3.0, "4.0": 5, "6": true}') |