Use unicode message if regex is also unicode in ExceptionInfo.match

This commit is contained in:
Bruno Oliveira
2019-06-30 10:34:40 -03:00
parent 86a4eb6008
commit 09dee292ca
2 changed files with 9 additions and 3 deletions

View File

@@ -572,9 +572,13 @@ class ExceptionInfo(object):
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