Added warning if defusedxml is not found

This commit is contained in:
Andrew Murray 2021-06-30 11:23:57 +10:00
parent d9d811ff21
commit 0aa8bd00e7
4 changed files with 7 additions and 3 deletions

View File

@ -831,7 +831,8 @@ class TestFileJpeg:
def test_getxmp(self):
with Image.open("Tests/images/xmp_test.jpg") as im:
if ElementTree is None:
assert xmp == {}
with pytest.warns(UserWarning):
assert im.getxmp() == {}
else:
xmp = im.getxmp()

View File

@ -659,7 +659,8 @@ class TestFilePng:
def test_getxmp(self):
with Image.open("Tests/images/color_snakes.png") as im:
if ElementTree is None:
assert im.getxmp() == {}
with pytest.warns(UserWarning):
assert im.getxmp() == {}
else:
xmp = im.getxmp()

View File

@ -651,7 +651,8 @@ class TestFileTiff:
def test_getxmp(self):
with Image.open("Tests/images/lab.tif") as im:
if ElementTree is None:
assert im.getxmp() == {}
with pytest.warns(UserWarning):
assert im.getxmp() == {}
else:
xmp = im.getxmp()

View File

@ -1364,6 +1364,7 @@ class Image:
return value
if ElementTree is None:
warnings.warn("XMP data cannot be read without defusedxml dependency")
return {}
else:
root = ElementTree.fromstring(xmp_tags)