Skip to content

Commit 34b4e21

Browse files
committed
Include two more cases for non-ascii encoded bytes
1 parent a886015 commit 34b4e21

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/_pytest/_code/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ def match(self, regexp):
577577
)
578578
if not re.search(regexp, value):
579579
raise AssertionError(
580-
u"Pattern '{}' not found in '{}'".format(regexp, value)
580+
u"Pattern {!r} not found in {!r}".format(regexp, value)
581581
)
582582
return True
583583

testing/python/raises.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def test_raises_match(self):
221221
int("asdf")
222222

223223
msg = "with base 16"
224-
expr = r"Pattern '{}' not found in 'invalid literal for int\(\) with base 10: 'asdf''".format(
224+
expr = r"Pattern '{}' not found in \"invalid literal for int\(\) with base 10: 'asdf'\"".format(
225225
msg
226226
)
227227
with pytest.raises(AssertionError, match=expr):
@@ -305,6 +305,18 @@ class TestUnicodeHandling:
305305
pytest.param(
306306
u"hello", b"world", pytest.raises(AssertionError), marks=py2_only
307307
),
308+
pytest.param(
309+
u"😊".encode("UTF-8"),
310+
b"world",
311+
pytest.raises(AssertionError),
312+
marks=py2_only,
313+
),
314+
pytest.param(
315+
u"world",
316+
u"😊".encode("UTF-8"),
317+
pytest.raises(AssertionError),
318+
marks=py2_only,
319+
),
308320
],
309321
)
310322
def test_handling(self, message, match, expectation):

0 commit comments

Comments
 (0)