Match warning message

This commit is contained in:
Andrew Murray 2023-10-06 17:31:06 +11:00
parent f24222a954
commit a3fd009875
4 changed files with 24 additions and 6 deletions

View File

@ -882,7 +882,10 @@ class TestFileJpeg:
def test_getxmp(self):
with Image.open("Tests/images/xmp_test.jpg") as im:
if ElementTree is None:
with pytest.warns(UserWarning):
with pytest.warns(
UserWarning,
match="XMP data cannot be read without defusedxml dependency",
):
assert im.getxmp() == {}
else:
xmp = im.getxmp()
@ -908,7 +911,10 @@ class TestFileJpeg:
def test_getxmp_no_prefix(self):
with Image.open("Tests/images/xmp_no_prefix.jpg") as im:
if ElementTree is None:
with pytest.warns(UserWarning):
with pytest.warns(
UserWarning,
match="XMP data cannot be read without defusedxml dependency",
):
assert im.getxmp() == {}
else:
assert im.getxmp() == {"xmpmeta": {"key": "value"}}
@ -916,7 +922,10 @@ class TestFileJpeg:
def test_getxmp_padded(self):
with Image.open("Tests/images/xmp_padded.jpg") as im:
if ElementTree is None:
with pytest.warns(UserWarning):
with pytest.warns(
UserWarning,
match="XMP data cannot be read without defusedxml dependency",
):
assert im.getxmp() == {}
else:
assert im.getxmp() == {"xmpmeta": None}

View File

@ -665,7 +665,10 @@ class TestFilePng:
def test_getxmp(self):
with Image.open("Tests/images/color_snakes.png") as im:
if ElementTree is None:
with pytest.warns(UserWarning):
with pytest.warns(
UserWarning,
match="XMP data cannot be read without defusedxml dependency",
):
assert im.getxmp() == {}
else:
xmp = im.getxmp()

View File

@ -734,7 +734,10 @@ class TestFileTiff:
def test_getxmp(self):
with Image.open("Tests/images/lab.tif") as im:
if ElementTree is None:
with pytest.warns(UserWarning):
with pytest.warns(
UserWarning,
match="XMP data cannot be read without defusedxml dependency",
):
assert im.getxmp() == {}
else:
xmp = im.getxmp()

View File

@ -118,7 +118,10 @@ def test_getxmp():
with Image.open("Tests/images/flower2.webp") as im:
if ElementTree is None:
with pytest.warns(UserWarning):
with pytest.warns(
UserWarning,
match="XMP data cannot be read without defusedxml dependency",
):
assert im.getxmp() == {}
else:
assert (