assertDictEqual fail text useless with OrderedDict

Currently, when a dictionary comparison fails with TestCase.assertDictEqual() between a dict and OrderedDict it just barfs out both dictionaries:

TestCase().assertDictEqual(dict(a=1,b=2,c=3), OrderedDict(a=1,b=3,c=3))
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "/usr/local/lib/python3.10/unittest/case.py", line 1144, in assertDictEqual
    self.fail(self._formatMessage(msg, standardMsg))
  File "/usr/local/lib/python3.10/unittest/case.py", line 675, in fail
    raise self.failureException(msg)
AssertionError: {'a': 1, 'b': 2, 'c': 3} != OrderedDict([('a', 1), ('b', 3), ('c', 3)])
- {'a': 1, 'b': 2, 'c': 3}
+ OrderedDict([('a', 1), ('b', 3), ('c', 3)])

Instead of the prettier dict/dict comparison:

TestCase().assertDictEqual(dict(a=1,b=2,c=3), dict(a=1,b=3,c=3))
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "/usr/local/lib/python3.10/unittest/case.py", line 1144, in assertDictEqual
    self.fail(self._formatMessage(msg, standardMsg))
  File "/usr/local/lib/python3.10/unittest/case.py", line 675, in fail
    raise self.failureException(msg)
AssertionError: {'a': 1, 'b': 2, 'c': 3} != {'a': 1, 'b': 3, 'c': 3}
- {'a': 1, 'b': 2, 'c': 3}
?               ^
+ {'a': 1, 'b': 3, 'c': 3}
?               ^

I’m aware that I could just cast it by using dict(my_ordered_dict), but considering OrderedDict is treated exactly the same as a regular dict 99% of the time this feels like unexpected behavior. Plus, if there is a nested OrderedDict I would have to cast it recursively or use the clunky json.loads(json.dumps(my_ordered_dict)) which may or may not support the types present in the object.

Please let me know if this is intended behavior.

There is room for improvement in assertDictEqual().

Currently, the code runs prettyprint on the two dicts, splits them into lines, and runs a diff on the lines. It is all text based but could be rewritten to be content based and just display the symmetric difference between items views of the two dicts:

d1 = {'a': 1, 'b': 2, 'c': 3}
d2 = OrderedDict([('a', 1), ('b', 3), ('c', 3)])
d1.items() ^ d2.items()
{('b', 2), ('b', 3)}

There may be reasons to stick with the text based approach, but none pop to mind at the moment.

Raymond