Address PR comments
This commit is contained in:
parent
85807ba368
commit
55a78b6973
|
@ -178,7 +178,7 @@ class PrettyPrinter:
|
|||
return
|
||||
cls = object.__class__
|
||||
stream.write(cls.__name__ + "(")
|
||||
self._pprint_dict(object, stream, indent, allowance, context, level)
|
||||
self._format(list(object.items()), stream, indent, allowance, context, level)
|
||||
stream.write(")")
|
||||
|
||||
_dispatch[_collections.OrderedDict.__repr__] = _pprint_ordered_dict
|
||||
|
@ -373,15 +373,9 @@ class PrettyPrinter:
|
|||
item_indent = indent + self._indent_per_level
|
||||
delimnl = "\n" + " " * item_indent
|
||||
|
||||
it = iter(items)
|
||||
while True:
|
||||
try:
|
||||
next_ent = next(it)
|
||||
except StopIteration:
|
||||
break
|
||||
|
||||
for item in items:
|
||||
write(delimnl)
|
||||
self._format(next_ent, stream, item_indent, 1, context, level)
|
||||
self._format(item, stream, item_indent, 1, context, level)
|
||||
write(",")
|
||||
|
||||
write("\n" + " " * indent)
|
||||
|
@ -412,10 +406,15 @@ class PrettyPrinter:
|
|||
_dispatch[_collections.defaultdict.__repr__] = _pprint_default_dict
|
||||
|
||||
def _pprint_counter(self, object, stream, indent, allowance, context, level):
|
||||
stream.write(object.__class__.__name__ + "({")
|
||||
stream.write(object.__class__.__name__ + "(")
|
||||
|
||||
if object:
|
||||
stream.write("{")
|
||||
items = object.most_common()
|
||||
self._format_dict_items(items, stream, indent, allowance, context, level)
|
||||
stream.write("})")
|
||||
stream.write("}")
|
||||
|
||||
stream.write(")")
|
||||
|
||||
_dispatch[_collections.Counter.__repr__] = _pprint_counter
|
||||
|
||||
|
|
|
@ -84,19 +84,28 @@ 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",
|
||||
),
|
||||
|
@ -244,7 +253,7 @@ class DataclassWithTwoItems:
|
|||
),
|
||||
pytest.param(
|
||||
Counter(),
|
||||
"Counter({})",
|
||||
"Counter()",
|
||||
id="counter-empty",
|
||||
),
|
||||
pytest.param(
|
||||
|
@ -380,10 +389,16 @@ class DataclassWithTwoItems:
|
|||
'one': 1,
|
||||
'two': 2,
|
||||
}),
|
||||
'ordereddict': OrderedDict({
|
||||
'one': 1,
|
||||
'two': 2,
|
||||
}),
|
||||
'ordereddict': OrderedDict([
|
||||
(
|
||||
'one',
|
||||
1,
|
||||
),
|
||||
(
|
||||
'two',
|
||||
2,
|
||||
),
|
||||
]),
|
||||
'set': {
|
||||
1,
|
||||
2,
|
||||
|
|
|
@ -754,6 +754,19 @@ class TestAssert_reprcompare:
|
|||
"+ 3,",
|
||||
" )",
|
||||
]
|
||||
lines = callequal((1, 2, 3), (1, 20, 3), verbose=2)
|
||||
assert lines == [
|
||||
"(1, 2, 3) == (1, 20, 3)",
|
||||
"At index 1 diff: 2 != 20",
|
||||
"Full diff:",
|
||||
" (",
|
||||
" 1,",
|
||||
"- 20,",
|
||||
"? -",
|
||||
"+ 2,",
|
||||
" 3,",
|
||||
" )",
|
||||
]
|
||||
|
||||
def test_set(self) -> None:
|
||||
expl = callequal({0, 1}, {0, 2})
|
||||
|
|
Loading…
Reference in New Issue