diff options
author | Raymond Hettinger <python@rcn.com> | 2009-05-27 06:50:31 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2009-05-27 06:50:31 (GMT) |
commit | c8d952dfe4e7c126675d097c921f348584d50ac3 (patch) | |
tree | 83f39606c0d4301eea857a89b107f8e141b4338a /Lib/json | |
parent | 0ffaaa634d59d24d2707adec7ff395f6fe51bb04 (diff) | |
download | cpython-c8d952dfe4e7c126675d097c921f348584d50ac3.zip cpython-c8d952dfe4e7c126675d097c921f348584d50ac3.tar.gz cpython-c8d952dfe4e7c126675d097c921f348584d50ac3.tar.bz2 |
Issue 6105: json encoder to respect iteration order of its inputs.
Diffstat (limited to 'Lib/json')
-rw-r--r-- | Lib/json/tests/test_encode_basestring_ascii.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/json/tests/test_encode_basestring_ascii.py b/Lib/json/tests/test_encode_basestring_ascii.py index 68ce7ef..8711469 100644 --- a/Lib/json/tests/test_encode_basestring_ascii.py +++ b/Lib/json/tests/test_encode_basestring_ascii.py @@ -1,6 +1,8 @@ from unittest import TestCase import json.encoder +from json import dumps +from collections import OrderedDict CASES = [ ('/\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\x08\x0c\n\r\t`1~!@#$%^&*()_+-=[]{}|;:\',./<>?', '"/\\\\\\"\\ucafe\\ubabe\\uab98\\ufcde\\ubcda\\uef4a\\b\\f\\n\\r\\t`1~!@#$%^&*()_+-=[]{}|;:\',./<>?"'), @@ -35,3 +37,9 @@ class TestEncodeBaseStringAscii(TestCase): self.assertEquals(result, expect, '{0!r} != {1!r} for {2}({3!r})'.format( result, expect, fname, input_string)) + + def test_ordered_dict(self): + # See issue 6105 + items = [('one', 1), ('two', 2), ('three', 3), ('four', 4), ('five', 5)] + s = json.dumps(OrderedDict(items)) + self.assertEqual(s, '{"one": 1, "two": 2, "three": 3, "four": 4, "five": 5}') |