diff options
| author | Senthil Kumaran <orsenthil@gmail.com> | 2011-04-13 01:35:37 (GMT) |
|---|---|---|
| committer | Senthil Kumaran <orsenthil@gmail.com> | 2011-04-13 01:35:37 (GMT) |
| commit | a8b0f9adfeac1aa5bb8189c46a9cc7d01f89d8a5 (patch) | |
| tree | 8b66d8bf9f0ddbaceb9fa9d39cf03c9390d13a6f /Lib/json/tests/test_indent.py | |
| parent | 60f02a650ed85a9985aba10a019df0a1f83d3554 (diff) | |
| parent | 3dd02d62c90a169a32fb38bed34249a6cf7e1638 (diff) | |
| download | cpython-a8b0f9adfeac1aa5bb8189c46a9cc7d01f89d8a5.zip cpython-a8b0f9adfeac1aa5bb8189c46a9cc7d01f89d8a5.tar.gz cpython-a8b0f9adfeac1aa5bb8189c46a9cc7d01f89d8a5.tar.bz2 | |
Merge updates
Diffstat (limited to 'Lib/json/tests/test_indent.py')
| -rw-r--r-- | Lib/json/tests/test_indent.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/json/tests/test_indent.py b/Lib/json/tests/test_indent.py index cd608d9..d45aa85 100644 --- a/Lib/json/tests/test_indent.py +++ b/Lib/json/tests/test_indent.py @@ -2,6 +2,7 @@ from unittest import TestCase import json import textwrap +from io import StringIO class TestIndent(TestCase): def test_indent(self): @@ -39,3 +40,18 @@ class TestIndent(TestCase): self.assertEqual(h1, h) self.assertEqual(h2, h) self.assertEqual(d2, expect) + + def test_indent0(self): + h = {3: 1} + def check(indent, expected): + d1 = json.dumps(h, indent=indent) + self.assertEqual(d1, expected) + + sio = StringIO() + json.dump(h, sio, indent=indent) + self.assertEqual(sio.getvalue(), expected) + + # indent=0 should emit newlines + check(0, '{\n"3": 1\n}') + # indent=None is more compact + check(None, '{"3": 1}') |
