-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Corrected check for libtiff feature #7975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Should we use |
|
Ok, I've updated the commit. |
nulano
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to use monkeypatch in case the save method raises an exception?
Tests/test_tiff_ifdrational.py
Outdated
| @pytest.mark.parametrize( | ||
| "libtiff", (pytest.param(True, marks=skip_unless_feature("libtiff")), False) | ||
| ) | ||
| def test_ifd_rational_save(tmp_path: Path, libtiff: bool) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| def test_ifd_rational_save(tmp_path: Path, libtiff: bool) -> None: | |
| def test_ifd_rational_save(monkeypatch: pytest.MonkeyPatch, tmp_path: Path, libtiff: bool) -> None: |
Tests/test_tiff_ifdrational.py
Outdated
| out = str(tmp_path / "temp.tiff") | ||
| res = IFDRational(301, 1) | ||
| im.save(out, dpi=(res, res), compression="raw") | ||
| TiffImagePlugin.WRITE_LIBTIFF = libtiff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| TiffImagePlugin.WRITE_LIBTIFF = libtiff | |
| monkeypatch.setattr(TiffImagePlugin, "WRITE_LIBTIFF", libtiff) |
Tests/test_tiff_ifdrational.py
Outdated
| im.save(out, dpi=(res, res), compression="raw") | ||
| TiffImagePlugin.WRITE_LIBTIFF = libtiff | ||
| im.save(out, dpi=(res, res), compression="raw") | ||
| TiffImagePlugin.WRITE_LIBTIFF = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| TiffImagePlugin.WRITE_LIBTIFF = False |
|
I've pushed a commit to use monkeypatch whenever the tests set |
Tests/test_file_libtiff.py
Outdated
| libtiffs = [] | ||
| libtiffs = [False] | ||
| if Image.core.libtiff_support_custom_tags: | ||
| libtiffs.append(True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can also use pytest.mark.parametrize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
nulano
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good; I just noticed one more test that can be parametrized.
Tests/test_imagesequence.py
Outdated
| TiffImagePlugin.READ_LIBTIFF = True | ||
| def test_libtiff(monkeypatch: pytest.MonkeyPatch) -> None: | ||
| monkeypatch.setattr(TiffImagePlugin, "READ_LIBTIFF", True) | ||
| _test_multipage_tiff() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While not as useful, these two tests can also be combined into one with pytest.mark.parametrize for slightly shorter code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, done
Pillow/Tests/test_tiff_ifdrational.py
Lines 55 to 61 in db21e7d
This is the wrong way around.
WRITE_LIBTIFFshould beTruewhen libtiff is available.To demonstrate, if I skip building libtiff on Windows, it fails. With this change, it passes.