Show bytes ascii representation instead of numeric value

This commit is contained in:
Bruno Oliveira
2019-06-25 20:30:18 -03:00
parent 8c7eb82363
commit 3f2344e8f7
3 changed files with 56 additions and 13 deletions

View File

@@ -331,17 +331,26 @@ class TestAssert_reprcompare:
assert "- spam" in diff
assert "+ eggs" in diff
def test_bytes_diff(self):
def test_bytes_diff_normal(self):
"""Check special handling for bytes diff (#5260)"""
diff = callequal(b"spam", b"eggs")
if PY3:
assert diff == [
"b'spam' == b'eggs'",
"At index 0 diff: 115 != 101",
"Use -v to get the full diff",
]
else:
# Handled as text on Python 2.
assert diff == ["'spam' == 'eggs'", "- spam", "+ eggs"]
assert diff == [
"b'spam' == b'eggs'",
"At index 0 diff: b's' != b'e'",
"Use -v to get the full diff",
]
def test_bytes_diff_verbose(self):
"""Check special handling for bytes diff (#5260)"""
diff = callequal(b"spam", b"eggs", verbose=True)
assert diff == [
"b'spam' == b'eggs'",
"At index 0 diff: b's' != b'e'",
"Full diff:",
"- b'spam'",
"+ b'eggs'",
]
def test_list(self):
expl = callequal([0, 1], [0, 2])