From a3fd0098750c17f4f944f7c2202f361c6e342be5 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Fri, 6 Oct 2023 17:31:06 +1100 Subject: [PATCH] Match warning message --- Tests/test_file_jpeg.py | 15 ++++++++++++--- Tests/test_file_png.py | 5 ++++- Tests/test_file_tiff.py | 5 ++++- Tests/test_file_webp_metadata.py | 5 ++++- 4 files changed, 24 insertions(+), 6 deletions(-) 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 (