summaryrefslogtreecommitdiff
path: root/testing/test_assertion.py
diff options
context:
space:
mode:
authorBruno Oliveira <nicoddemus@gmail.com>2019-06-25 20:30:18 -0300
committerBruno Oliveira <nicoddemus@gmail.com>2019-06-25 20:40:25 -0300
commit3f2344e8f73784b40df28d82a44249827206dc63 (patch)
tree11d3790a3a0161533edefdf9bddface826602e24 /testing/test_assertion.py
parent8c7eb8236348c8fb8db43a6a9c02ba442a09f6b8 (diff)
downloadpytest-3f2344e8f73784b40df28d82a44249827206dc63.tar.gz
Show bytes ascii representation instead of numeric value
Diffstat (limited to 'testing/test_assertion.py')
-rw-r--r--testing/test_assertion.py29
1 files changed, 19 insertions, 10 deletions
diff --git a/testing/test_assertion.py b/testing/test_assertion.py
index f9c67d703..f58d240a5 100644
--- a/testing/test_assertion.py
+++ b/testing/test_assertion.py
@@ -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])