diff options
| author | Raymond Hettinger <python@rcn.com> | 2010-10-30 07:29:44 (GMT) |
|---|---|---|
| committer | Raymond Hettinger <python@rcn.com> | 2010-10-30 07:29:44 (GMT) |
| commit | cbba8d4c7a5b77ef60c088b5070b919b32a1b861 (patch) | |
| tree | 7c2b4561d548e954073f0e34807e04db19d0d484 /Lib/json/tests | |
| parent | 5306234655e6d7f398761214bf0e71491c3c7211 (diff) | |
| download | cpython-cbba8d4c7a5b77ef60c088b5070b919b32a1b861.zip cpython-cbba8d4c7a5b77ef60c088b5070b919b32a1b861.tar.gz cpython-cbba8d4c7a5b77ef60c088b5070b919b32a1b861.tar.bz2 | |
Backport r72961 fixing issue #6105: json.dumps not following OrderedDict iteration order.
Diffstat (limited to 'Lib/json/tests')
| -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 62abe5b..02889f0 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 = [ (u'/\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\x08\x0c\n\r\t`1~!@#$%^&*()_+-=[]{}|;:\',./<>?', '"/\\\\\\"\\ucafe\\ubabe\\uab98\\ufcde\\ubcda\\uef4a\\b\\f\\n\\r\\t`1~!@#$%^&*()_+-=[]{}|;:\',./<>?"'), @@ -37,3 +39,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}') |
