Merge pull request #8000 from radarhere/libtiff

This commit is contained in:
Hugo van Kemenade 2024-04-22 22:56:30 +03:00 committed by GitHub
commit 1c21cd41bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -242,7 +242,24 @@ class TestFileLibTiff(LibTiffTestCase):
im.save(out, tiffinfo=new_ifd)
def test_custom_metadata(self, tmp_path: Path) -> None:
@pytest.mark.parametrize(
"libtiff",
(
pytest.param(
True,
marks=pytest.mark.skipif(
not getattr(Image.core, "libtiff_support_custom_tags", False),
reason="Custom tags not supported by older libtiff",
),
),
False,
),
)
def test_custom_metadata(
self, monkeypatch: pytest.MonkeyPatch, tmp_path: Path, libtiff: bool
) -> None:
monkeypatch.setattr(TiffImagePlugin, "WRITE_LIBTIFF", libtiff)
class Tc(NamedTuple):
value: Any
type: int
@ -281,13 +298,6 @@ class TestFileLibTiff(LibTiffTestCase):
)
}
libtiffs = [False]
if Image.core.libtiff_support_custom_tags:
libtiffs.append(True)
for libtiff in libtiffs:
TiffImagePlugin.WRITE_LIBTIFF = libtiff
def check_tags(
tiffinfo: TiffImagePlugin.ImageFileDirectory_v2 | dict[int, str]
) -> None:
@ -304,9 +314,7 @@ class TestFileLibTiff(LibTiffTestCase):
and libtiff
):
# libtiff does not support real RATIONALS
assert (
round(abs(float(reloaded_value) - float(value)), 7) == 0
)
assert round(abs(float(reloaded_value) - float(value)), 7) == 0
continue
assert reloaded_value == value
@ -327,7 +335,6 @@ class TestFileLibTiff(LibTiffTestCase):
if tagdata.supported_by_default
}
)
TiffImagePlugin.WRITE_LIBTIFF = False
def test_osubfiletype(self, tmp_path: Path) -> None:
outfile = str(tmp_path / "temp.tif")
@ -741,7 +748,7 @@ class TestFileLibTiff(LibTiffTestCase):
pytest.param(
True,
marks=pytest.mark.skipif(
not Image.core.libtiff_support_custom_tags,
not getattr(Image.core, "libtiff_support_custom_tags", False),
reason="Custom tags not supported by older libtiff",
),
),