Include two more cases for non-ascii encoded bytes

This commit is contained in:
Bruno Oliveira 2019-07-04 09:34:55 -03:00
parent a886015bfd
commit 34b4e21606
2 changed files with 14 additions and 2 deletions

View File

@ -577,7 +577,7 @@ class ExceptionInfo(object):
) )
if not re.search(regexp, value): if not re.search(regexp, value):
raise AssertionError( raise AssertionError(
u"Pattern '{}' not found in '{}'".format(regexp, value) u"Pattern {!r} not found in {!r}".format(regexp, value)
) )
return True return True

View File

@ -221,7 +221,7 @@ class TestRaises(object):
int("asdf") int("asdf")
msg = "with base 16" msg = "with base 16"
expr = r"Pattern '{}' not found in 'invalid literal for int\(\) with base 10: 'asdf''".format( expr = r"Pattern '{}' not found in \"invalid literal for int\(\) with base 10: 'asdf'\"".format(
msg msg
) )
with pytest.raises(AssertionError, match=expr): with pytest.raises(AssertionError, match=expr):
@ -305,6 +305,18 @@ class TestUnicodeHandling:
pytest.param( pytest.param(
u"hello", b"world", pytest.raises(AssertionError), marks=py2_only u"hello", b"world", pytest.raises(AssertionError), marks=py2_only
), ),
pytest.param(
u"😊".encode("UTF-8"),
b"world",
pytest.raises(AssertionError),
marks=py2_only,
),
pytest.param(
u"world",
u"😊".encode("UTF-8"),
pytest.raises(AssertionError),
marks=py2_only,
),
], ],
) )
def test_handling(self, message, match, expectation): def test_handling(self, message, match, expectation):