Skip to content

Commit 7102980

Browse files
committed
Corrected check for libtiff feature
1 parent db21e7d commit 7102980

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

Tests/test_tiff_ifdrational.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
from fractions import Fraction
44
from pathlib import Path
55

6-
from PIL import Image, TiffImagePlugin, features
6+
import pytest
7+
8+
from PIL import Image, TiffImagePlugin
79
from PIL.TiffImagePlugin import IFDRational
810

9-
from .helper import hopper
11+
from .helper import hopper, skip_unless_feature
1012

1113

1214
def _test_equal(num, denom, target) -> None:
@@ -52,18 +54,17 @@ def test_nonetype() -> None:
5254
assert xres and yres
5355

5456

55-
def test_ifd_rational_save(tmp_path: Path) -> None:
56-
methods = [True]
57-
if features.check("libtiff"):
58-
methods.append(False)
59-
60-
for libtiff in methods:
61-
TiffImagePlugin.WRITE_LIBTIFF = libtiff
57+
@pytest.mark.parametrize(
58+
"libtiff", (pytest.param(True, marks=skip_unless_feature("libtiff")), False)
59+
)
60+
def test_ifd_rational_save(tmp_path: Path, libtiff: bool) -> None:
61+
im = hopper()
62+
out = str(tmp_path / "temp.tiff")
63+
res = IFDRational(301, 1)
6264

63-
im = hopper()
64-
out = str(tmp_path / "temp.tiff")
65-
res = IFDRational(301, 1)
66-
im.save(out, dpi=(res, res), compression="raw")
65+
TiffImagePlugin.WRITE_LIBTIFF = libtiff
66+
im.save(out, dpi=(res, res), compression="raw")
67+
TiffImagePlugin.WRITE_LIBTIFF = False
6768

68-
with Image.open(out) as reloaded:
69-
assert float(IFDRational(301, 1)) == float(reloaded.tag_v2[282])
69+
with Image.open(out) as reloaded:
70+
assert float(IFDRational(301, 1)) == float(reloaded.tag_v2[282])

0 commit comments

Comments
 (0)