improve failure output
This commit is contained in:
parent
2bffd6829e
commit
b83e97802e
|
@ -345,15 +345,13 @@ def _compare_eq_cls(left, right, verbose, type_fns):
|
|||
if same and verbose < 2:
|
||||
explanation.append(u"Omitting %s identical items, use -vv to show" % len(same))
|
||||
elif same:
|
||||
explanation += [u"Common attributes:"]
|
||||
explanation += [u"Matching attributes:"]
|
||||
explanation += pprint.pformat(same).splitlines()
|
||||
if diff:
|
||||
class_name = left.__class__.__name__
|
||||
explanation += [u"Differing attributes:"]
|
||||
for k in diff:
|
||||
for field in diff:
|
||||
explanation += [
|
||||
(u"%s(%s=%r) != %s(%s=%r)")
|
||||
% (class_name, k, getattr(left, k), class_name, k, getattr(right, k))
|
||||
(u"%s: %r != %r") % (field, getattr(left, field), getattr(right, field))
|
||||
]
|
||||
return explanation
|
||||
|
||||
|
|
|
@ -559,7 +559,7 @@ class TestAssert_reprcompare_dataclass(object):
|
|||
[
|
||||
"*Omitting 1 identical items, use -vv to show*",
|
||||
"*Differing attributes:*",
|
||||
"*SimpleDataObject(field_b='b') != SimpleDataObject(field_b='c')*",
|
||||
"*field_b: 'b' != 'c'*",
|
||||
]
|
||||
)
|
||||
|
||||
|
@ -570,10 +570,10 @@ class TestAssert_reprcompare_dataclass(object):
|
|||
result.assert_outcomes(failed=1, passed=0)
|
||||
result.stdout.fnmatch_lines(
|
||||
[
|
||||
"*Common attributes:*",
|
||||
"*Matching attributes:*",
|
||||
"*['field_a']*",
|
||||
"*Differing attributes:*",
|
||||
"*SimpleDataObject(field_b='b') != SimpleDataObject(field_b='c')*",
|
||||
"*field_b: 'b' != 'c'*",
|
||||
]
|
||||
)
|
||||
|
||||
|
@ -606,7 +606,7 @@ class TestAssert_reprcompare_attrsclass(object):
|
|||
|
||||
lines = callequal(left, right)
|
||||
assert lines[1].startswith("Omitting 1 identical item")
|
||||
assert "Common attributes" not in lines
|
||||
assert "Matching attributes" not in lines
|
||||
for line in lines[1:]:
|
||||
assert "field_a" not in line
|
||||
|
||||
|
@ -620,7 +620,7 @@ class TestAssert_reprcompare_attrsclass(object):
|
|||
right = SimpleDataObject(1, "c")
|
||||
|
||||
lines = callequal(left, right, verbose=2)
|
||||
assert lines[1].startswith("Common attributes:")
|
||||
assert lines[1].startswith("Matching attributes:")
|
||||
assert "Omitting" not in lines[1]
|
||||
assert lines[2] == "['field_a']"
|
||||
|
||||
|
@ -634,7 +634,7 @@ class TestAssert_reprcompare_attrsclass(object):
|
|||
right = SimpleDataObject(1, "b")
|
||||
|
||||
lines = callequal(left, right, verbose=2)
|
||||
assert lines[1].startswith("Common attributes:")
|
||||
assert lines[1].startswith("Matching attributes:")
|
||||
assert "Omitting" not in lines[1]
|
||||
assert lines[2] == "['field_a']"
|
||||
for line in lines[2:]:
|
||||
|
|
Loading…
Reference in New Issue