diff options
author | RĂ©mi Lapeyre <remi.lapeyre@henki.fr> | 2019-03-22 17:22:20 (GMT) |
---|---|---|
committer | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2019-03-22 17:22:20 (GMT) |
commit | 96831c7fcf888af187bbae8254608cccb4d6a03c (patch) | |
tree | 6f3c58afe8aeea2e3991a8bccdc6d0a63253625f /Lib/test/test_pprint.py | |
parent | c5c6cdada3d41148bdeeacfe7528327b481c5d18 (diff) | |
download | cpython-96831c7fcf888af187bbae8254608cccb4d6a03c.zip cpython-96831c7fcf888af187bbae8254608cccb4d6a03c.tar.gz cpython-96831c7fcf888af187bbae8254608cccb4d6a03c.tar.bz2 |
bpo-30670: Add pp function to the pprint module (GH-11769)
Diffstat (limited to 'Lib/test/test_pprint.py')
-rw-r--r-- | Lib/test/test_pprint.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_pprint.py b/Lib/test/test_pprint.py index 7ebc298..269ac06 100644 --- a/Lib/test/test_pprint.py +++ b/Lib/test/test_pprint.py @@ -81,6 +81,7 @@ class QueryTestCase(unittest.TestCase): pp = pprint.PrettyPrinter(indent=4, width=40, depth=5, stream=io.StringIO(), compact=True) pp = pprint.PrettyPrinter(4, 40, 5, io.StringIO()) + pp = pprint.PrettyPrinter(sort_dicts=False) with self.assertRaises(TypeError): pp = pprint.PrettyPrinter(4, 40, 5, io.StringIO(), True) self.assertRaises(ValueError, pprint.PrettyPrinter, indent=-1) @@ -293,6 +294,12 @@ class QueryTestCase(unittest.TestCase): self.assertEqual(pprint.pformat({"xy\tab\n": (3,), 5: [[]], (): {}}), r"{5: [[]], 'xy\tab\n': (3,), (): {}}") + def test_sort_dict(self): + d = dict.fromkeys('cba') + self.assertEqual(pprint.pformat(d, sort_dicts=False), "{'c': None, 'b': None, 'a': None}") + self.assertEqual(pprint.pformat([d, d], sort_dicts=False), + "[{'c': None, 'b': None, 'a': None}, {'c': None, 'b': None, 'a': None}]") + def test_ordered_dict(self): d = collections.OrderedDict() self.assertEqual(pprint.pformat(d, width=1), 'OrderedDict()') |