File tree 2 files changed +9
-3
lines changed
2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -572,9 +572,13 @@ def match(self, regexp):
572
572
raised.
573
573
"""
574
574
__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
+ )
576
578
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
+ )
578
582
return True
579
583
580
584
Original file line number Diff line number Diff line change @@ -279,6 +279,8 @@ def __class__(self):
279
279
pass
280
280
assert "via __class__" in excinfo .value .args [0 ]
281
281
282
- def test_u (self ):
282
+ def test_unicode_message (self ):
283
+ """pytest.raises should be able to match unicode messages when using a unicode regex (#5478)
284
+ """
283
285
with pytest .raises (AssertionError , match = u"\u2603 " ):
284
286
assert False , u"\u2603 "
You can’t perform that action at this time.
0 commit comments