diff -r e7706bdaaa0d Lib/json/__init__.py --- a/Lib/json/__init__.py Fri Jan 27 09:48:47 2012 +0100 +++ b/Lib/json/__init__.py Mon Feb 06 14:02:31 2012 -0500 @@ -31,7 +31,9 @@ Compact encoding:: >>> import json - >>> json.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',', ':')) + >>> from collections import OrderedDict + >>> mydict = OrderedDict([('4', 5), ('6', 7)]) + >>> json.dumps([1,2,3,mydict], separators=(',', ':')) '[1,2,3,{"4":5,"6":7}]' Pretty printing:: diff -r e7706bdaaa0d Lib/test/mapping_tests.py --- a/Lib/test/mapping_tests.py Fri Jan 27 09:48:47 2012 +0100 +++ b/Lib/test/mapping_tests.py Mon Feb 06 14:02:31 2012 -0500 @@ -14,7 +14,7 @@ def _reference(self): """Return a dictionary of values which are invariant by storage in the object under test.""" - return {1:2, "key1":"value1", "key2":(1,2,3)} + return {"1": "2", "key1":"value1", "key2":(1,2,3)} def _empty_mapping(self): """Return an empty mapping object""" return self.type2test() diff -r e7706bdaaa0d Lib/test/test_descr.py --- a/Lib/test/test_descr.py Fri Jan 27 09:48:47 2012 +0100 +++ b/Lib/test/test_descr.py Mon Feb 06 14:02:31 2012 -0500 @@ -4300,8 +4300,18 @@ def test_repr(self): # Testing dict_proxy.__repr__ + def sorted_dict_repr(repr_): + # Given the repr of a dict, sort the keys + assert repr_.startswith('{') + assert repr_.endswith('}') + kvs = repr_[1:-1].split(', ') + return '{' + ', '.join(sorted(kvs)) + '}' dict_ = {k: v for k, v in self.C.__dict__.items()} - self.assertEqual(repr(self.C.__dict__), 'dict_proxy({!r})'.format(dict_)) + repr_ = repr(self.C.__dict__) + self.assert_(repr_.startswith('dict_proxy(')) + self.assert_(repr_.endswith(')')) + self.assertEqual(sorted_dict_repr(repr_[len('dict_proxy('):-len(')')]), + sorted_dict_repr('{!r}'.format(dict_))) class PTypesLongInitTest(unittest.TestCase): diff -r e7706bdaaa0d Lib/test/test_set.py --- a/Lib/test/test_set.py Fri Jan 27 09:48:47 2012 +0100 +++ b/Lib/test/test_set.py Mon Feb 06 14:02:31 2012 -0500 @@ -734,6 +734,17 @@ if self.repr is not None: self.assertEqual(repr(self.set), self.repr) + def check_repr_against_values(self): + text = repr(self.set) + self.assertTrue(text.startswith('{')) + self.assertTrue(text.endswith('}')) + + result = text[1:-1].split(', ') + result.sort() + sorted_repr_values = [repr(value) for value in self.values] + sorted_repr_values.sort() + self.assertEqual(result, sorted_repr_values) + def test_print(self): try: fo = open(support.TESTFN, "w") @@ -892,7 +903,9 @@ self.set = set(self.values) self.dup = set(self.values) self.length = 3 - self.repr = "{'a', 'c', 'b'}" + + def test_repr(self): + self.check_repr_against_values() #------------------------------------------------------------------------------ @@ -903,7 +916,9 @@ self.set = set(self.values) self.dup = set(self.values) self.length = 3 - self.repr = "{b'a', b'c', b'b'}" + + def test_repr(self): + self.check_repr_against_values() #------------------------------------------------------------------------------ @@ -916,11 +931,13 @@ self.set = set(self.values) self.dup = set(self.values) self.length = 4 - self.repr = "{'a', b'a', 'b', b'b'}" def tearDown(self): warnings.filters = self.warning_filters + def test_repr(self): + self.check_repr_against_values() + #============================================================================== def baditer(): diff -r e7706bdaaa0d Lib/test/test_urllib.py --- a/Lib/test/test_urllib.py Fri Jan 27 09:48:47 2012 +0100 +++ b/Lib/test/test_urllib.py Mon Feb 06 14:02:31 2012 -0500 @@ -12,6 +12,7 @@ import sys import tempfile import warnings +import collections def hexescape(char): """Escape char as RFC 2396 specifies""" @@ -840,8 +841,9 @@ self.assertEqual("a=1&a=2", urllib.parse.urlencode({"a": [1, 2]}, True)) self.assertEqual("a=None&a=a", urllib.parse.urlencode({"a": [None, "a"]}, True)) + data = collections.OrderedDict([("a", 1), ("b", 1)]) self.assertEqual("a=a&a=b", - urllib.parse.urlencode({"a": {"a": 1, "b": 1}}, True)) + urllib.parse.urlencode({"a": data}, True)) def test_urlencode_encoding(self): # ASCII encoding. Expect %3F with errors="replace' diff -r e7706bdaaa0d Lib/tkinter/test/test_ttk/test_functions.py --- a/Lib/tkinter/test/test_ttk/test_functions.py Fri Jan 27 09:48:47 2012 +0100 +++ b/Lib/tkinter/test/test_ttk/test_functions.py Mon Feb 06 14:02:31 2012 -0500 @@ -143,7 +143,7 @@ ('a', 'b', 'c')), ("test {a b} c", ())) # state spec and options self.assertEqual(ttk._format_elemcreate('image', False, 'test', - ('a', 'b'), a='x', b='y'), ("test a b", ("-a", "x", "-b", "y"))) + ('a', 'b'), a='x'), ("test a b", ("-a", "x"))) # format returned values as a tcl script # state spec with multiple states and an option with a multivalue self.assertEqual(ttk._format_elemcreate('image', True, 'test',