diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2012-07-21 09:22:33 (GMT) |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2012-07-21 09:22:33 (GMT) |
commit | 6a01fc5d4114ac56105ecbfb4ae3cbe043818449 (patch) | |
tree | d09a5ce0c25ed803f9d8c1f8e54bcf1ca5e5847e /Lib/test/test_pprint.py | |
parent | 5116704ec5f12e68835bc0280bb8547eb457a5c7 (diff) | |
parent | d6da90f93d6d44365f5c9f6a2290be90ccfc8d60 (diff) | |
download | cpython-6a01fc5d4114ac56105ecbfb4ae3cbe043818449.zip cpython-6a01fc5d4114ac56105ecbfb4ae3cbe043818449.tar.gz cpython-6a01fc5d4114ac56105ecbfb4ae3cbe043818449.tar.bz2 |
Issues #10017 and #14998: Fix TypeError using pprint on dictionaries with unorderable key.
Diffstat (limited to 'Lib/test/test_pprint.py')
-rw-r--r-- | Lib/test/test_pprint.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_pprint.py b/Lib/test/test_pprint.py index b26291b..95ffab7 100644 --- a/Lib/test/test_pprint.py +++ b/Lib/test/test_pprint.py @@ -466,6 +466,15 @@ class QueryTestCase(unittest.TestCase): self.assertEqual(clean(pprint.pformat(dict.fromkeys(keys))), '{' + ','.join('%r:None' % k for k in skeys) + '}') + # Issue 10017: TypeError on user-defined types as dict keys. + self.assertEqual(pprint.pformat({Unorderable: 0, 1: 0}), + '{1: 0, ' + repr(Unorderable) +': 0}') + + # Issue 14998: TypeError on tuples with NoneTypes as dict keys. + self.assertEqual(pprint.pformat({(1,): 0, (None,): 0}), + '{(1,): 0, (None,): 0}') + + class DottedPrettyPrinter(pprint.PrettyPrinter): def format(self, object, context, maxlevels, level): |