diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 8c73ccc6adc..1b6a765d0cd 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -572,6 +572,11 @@ def match(self, regexp): raised. """ __tracebackhide__ = True + if isinstance(regexp, text_type): + if not re.search(regexp, text_type(self.value)): + assert 0, u"Pattern '{!s}' not found in '{!s}'".format(regexp, self.value) + return True + if not re.search(regexp, str(self.value)): assert 0, "Pattern '{!s}' not found in '{!s}'".format(regexp, self.value) return True