Skip to content

Commit

Permalink
Catch defusedxml warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Aug 23, 2024
1 parent d6cfebd commit fed9168
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion Tests/test_file_webp_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,15 @@ def test_read_no_exif() -> None:
def test_getxmp() -> None:
with Image.open("Tests/images/flower.webp") as im:
assert "xmp" not in im.info
assert im.getxmp() == {}
if ElementTree is None:
with pytest.warns(
UserWarning,
match="XMP data cannot be read without defusedxml dependency",
):
xmp = im.getxmp()
else:
xmp = im.getxmp()
assert xmp == {}

with Image.open("Tests/images/flower2.webp") as im:
if ElementTree is None:
Expand Down
10 changes: 9 additions & 1 deletion Tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,15 @@ def test_exif_hide_offsets(self) -> None:

def test_empty_xmp(self) -> None:
with Image.open("Tests/images/hopper.gif") as im:
assert im.getxmp() == {}
if ElementTree is None:
with pytest.warns(
UserWarning,
match="XMP data cannot be read without defusedxml dependency",
):
xmp = im.getxmp()
else:
xmp = im.getxmp()
assert xmp == {}

def test_getxmp_padded(self) -> None:
im = Image.new("RGB", (1, 1))
Expand Down

0 comments on commit fed9168

Please sign in to comment.