[issue30670] pprint for dict in sorted order or insert order?

Joachim Jablon report at bugs.python.org
Mon Feb 4 16:57:48 EST 2019


Joachim Jablon <ewjoachim at gmail.com> added the comment:

If you stop sorting keys in pprint, then unittest.TestCase.assertDictEquals() (and pytest and such) won't be able to generate a meaningful diff when 2 dicts aren't equal, and it will be much more complicated to understand why a test fails.

https://github.com/python/cpython/blob/89427cd0feae25bbc8693abdccfa6a8c81a2689c/Lib/unittest/case.py#L1172-L1175

(well except if we fix unittest, but then external test runners will need fixing too, and it might not be the only place diff is used on the result of pprint to see how two objects differ)

----------
nosy: +ewjoachim

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue30670>
_______________________________________


More information about the Python-bugs-list mailing list