Re-print the ordered dict as a normal dict

This commit is contained in:
Benjamin Schubert 2023-11-27 13:55:46 +00:00
parent 55a78b6973
commit ccfb6691df
2 changed files with 12 additions and 27 deletions

View File

@ -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

View File

@ -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,