Skip to content

Commit 2cdc20b

Browse files
committed
Use unicode message if regex is also unicode in ExceptionInfo.match
1 parent 86a4eb6 commit 2cdc20b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/_pytest/_code/code.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,13 @@ def match(self, regexp):
572572
raised.
573573
"""
574574
__tracebackhide__ = True
575-
value = safe_str(self.value)
575+
value = (
576+
text_type(self.value) if isinstance(regexp, text_type) else str(self.value)
577+
)
576578
if not re.search(regexp, value):
577-
assert 0, "Pattern '{!s}' not found in '{!s}'".format(regexp, value)
579+
raise AssertionError(
580+
"Pattern '{!s}' not found in '{!s}'".format(regexp, value)
581+
)
578582
return True
579583

580584

0 commit comments

Comments
 (0)