You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think a simple difflib.ndiff over pprint is a bad choice for 'assertDictEqual`. The output it gives is often very confusing, like this:
E AssertionError: {'second': 2, 'seventh': 7, 'sixth': 6, 'fo[53 chars]': 3} != {'first': 1, 'seventh': 7, 'ninth': 9, 'sec[66 chars]': 3}
E {'eighth': 8,
E 'fifth': 5,
E 'first': 1,
E 'fourth': 4,
E + 'ninth': 9,
E 'second': 2,
E 'seventh': 7,
E - 'sixth': 6,
E - 'third': 3}
E ? ^
E
E + 'third': 3,
E ? ^
E
E + 'zeroth': 0}
I put together a better implementation which gives much nicer output, handles nested structures, and is WAY faster than the current implementation for the test given.
E AssertionError: {'second': 2, 'seventh': 7, 'sixth': 6, 'fo[53 chars]': 3} != {'first': 1, 'seventh': 7, 'ninth': 9, 'sec[66 chars]': 3}
E
E Diff:
E {
E 'eighth': 8,
E 'fifth': 5,
E 'first': 1,
E 'fourth': 4,
E 'second': 2,
E 'seventh': 7,
E 'third': 3,
E - 'sixth': 6,
E + 'ninth': 9,
E + 'zeroth': 0,
E }
I would be happy to contribute my code if that is desired.
Uh oh!
There was an error while loading. Please reload this page.
Calling assertDictEqual(d1, d2) / takes forever, even for medium-size dictionaries. To reproduce:
Probably related to issue #63416.
Tested on Python 3.10, Windows 11
Linked PRs
The text was updated successfully, but these errors were encountered: