summaryrefslogtreecommitdiffstats
path: root/Lib/json/tests
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2009-05-27 09:58:34 (GMT)
committerRaymond Hettinger <python@rcn.com>2009-05-27 09:58:34 (GMT)
commitbcf6f92dc50c1f23ca327c5dae4d616cfe212625 (patch)
tree6c178b09a815e9fdd9e7ba250940d380b973b83d /Lib/json/tests
parent81c0dcee658af0966bc91fe20ce2cd807a797aff (diff)
downloadcpython-bcf6f92dc50c1f23ca327c5dae4d616cfe212625.zip
cpython-bcf6f92dc50c1f23ca327c5dae4d616cfe212625.tar.gz
cpython-bcf6f92dc50c1f23ca327c5dae4d616cfe212625.tar.bz2
* Fix-up a TODO (support the sort_key option).
* Fix an error where True/False were being written-out as title-cased strings when used a dictionary keys. * Speed-up iteration over dicts by looping over items() rather than keys() followed by value lookups. * TODO: sort only by keys, not keys and values.
Diffstat (limited to 'Lib/json/tests')
-rw-r--r--Lib/json/tests/test_encode_basestring_ascii.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/json/tests/test_encode_basestring_ascii.py b/Lib/json/tests/test_encode_basestring_ascii.py
index 8711469..dbcb09a 100644
--- a/Lib/json/tests/test_encode_basestring_ascii.py
+++ b/Lib/json/tests/test_encode_basestring_ascii.py
@@ -43,3 +43,8 @@ class TestEncodeBaseStringAscii(TestCase):
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}')
+
+ def test_sorted_dict(self):
+ items = [('one', 1), ('two', 2), ('three', 3), ('four', 4), ('five', 5)]
+ s = json.dumps(dict(items), sort_keys=True)
+ self.assertEqual(s, '{"five": 5, "four": 4, "one": 1, "three": 3, "two": 2}')