diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py index 4d350f5d2ff..769d7ed969a 100644 --- a/Tests/test_file_jpeg.py +++ b/Tests/test_file_jpeg.py @@ -882,7 +882,10 @@ def read(n=-1): 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 @@ def test_getxmp(self): 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 @@ def test_getxmp_no_prefix(self): 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} diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index eea9f73d866..40fc595ad52 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -665,7 +665,10 @@ def test_plte_length(self, tmp_path): 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() diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py index f13436ce868..7362c93cac8 100644 --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -734,7 +734,10 @@ def test_discard_icc_profile(self, tmp_path): 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() diff --git a/Tests/test_file_webp_metadata.py b/Tests/test_file_webp_metadata.py index 037479f9fbb..dd47be8b21b 100644 --- a/Tests/test_file_webp_metadata.py +++ b/Tests/test_file_webp_metadata.py @@ -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 (