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 4d350f5d2..769d7ed96 100644 --- a/Tests/test_file_jpeg.py +++ b/Tests/test_file_jpeg.py @@ -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} diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index eea9f73d8..40fc595ad 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -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() diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py index f13436ce8..7362c93ca 100644 --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -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() diff --git a/Tests/test_file_webp_metadata.py b/Tests/test_file_webp_metadata.py index 037479f9f..dd47be8b2 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 (