diff --git a/src/_pytest/_io/pprint.py b/src/_pytest/_io/pprint.py index e922d7156..bb59253f7 100644 --- a/src/_pytest/_io/pprint.py +++ b/src/_pytest/_io/pprint.py @@ -178,7 +178,7 @@ class PrettyPrinter: return cls = object.__class__ stream.write(cls.__name__ + "(") - self._format(list(object.items()), stream, indent, allowance, context, level) + self._pprint_dict(object, stream, indent, allowance, context, level) stream.write(")") _dispatch[_collections.OrderedDict.__repr__] = _pprint_ordered_dict diff --git a/testing/io/test_pprint.py b/testing/io/test_pprint.py index 3ed601972..3432c63f6 100644 --- a/testing/io/test_pprint.py +++ b/testing/io/test_pprint.py @@ -84,28 +84,19 @@ class DataclassWithTwoItems: pytest.param( OrderedDict({"one": 1}), """ - OrderedDict([ - ( - 'one', - 1, - ), - ]) + OrderedDict({ + 'one': 1, + }) """, id="ordereddict-one-item", ), pytest.param( OrderedDict({"one": 1, "two": 2}), """ - OrderedDict([ - ( - 'one', - 1, - ), - ( - 'two', - 2, - ), - ]) + OrderedDict({ + 'one': 1, + 'two': 2, + }) """, id="ordereddict-two-items", ), @@ -389,16 +380,10 @@ class DataclassWithTwoItems: 'one': 1, 'two': 2, }), - 'ordereddict': OrderedDict([ - ( - 'one', - 1, - ), - ( - 'two', - 2, - ), - ]), + 'ordereddict': OrderedDict({ + 'one': 1, + 'two': 2, + }), 'set': { 1, 2,