Skip to content

Commit

Permalink
Use unicode message if regex is also unicode in ExceptionInfo.match
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus committed Jun 30, 2019
1 parent 86a4eb6 commit 2cdc20b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/_pytest/_code/code.py
Expand Up @@ -572,9 +572,13 @@ def match(self, regexp):
raised.
"""
__tracebackhide__ = True
value = safe_str(self.value)
value = (
text_type(self.value) if isinstance(regexp, text_type) else str(self.value)
)
if not re.search(regexp, value):
assert 0, "Pattern '{!s}' not found in '{!s}'".format(regexp, value)
raise AssertionError(
"Pattern '{!s}' not found in '{!s}'".format(regexp, value)
)
return True


Expand Down

0 comments on commit 2cdc20b

Please sign in to comment.