imagecms testing

This commit is contained in:
Deekshu Kare 2024-06-21 23:02:29 +02:00
parent c1d7543156
commit f18d64c267

View File

@ -0,0 +1,46 @@
import pytest
from PIL import ImageCms
from PIL.ImageCms import ImageCmsProfile
def test_ImageCmsProfile_init():
# Test with a filename
profile_filename = "path/to/profile.icc"
profile = ImageCmsProfile(profile_filename)
assert profile.filename == profile_filename
# Test with a file-like object
profile_file = open("path/to/profile.icc", "rb")
profile = ImageCmsProfile(profile_file)
assert profile.filename is None
# Test with a low-level profile object
low_level_profile = core.profile_open(profile_filename)
profile = ImageCmsProfile(low_level_profile)
assert profile.filename is None
# Test with an invalid type
with pytest.raises(TypeError):
ImageCmsProfile(123)
# def test_ImageCmsProfile_init_win32():
# profile_path = "path/to/profile.icc"
# profile_bytes = b"ICC_PROFILE_DATA"
# with open(profile_path, "rb") as f:
# profile_data = f.read()
# with pytest.raises(TypeError):
# ImageCmsProfile(profile_path)
# with pytest.raises(TypeError):
# ImageCmsProfile(profile_bytes)
# profile = ImageCmsProfile(profile_data)
# assert profile.filename is None
# assert profile.profile is not None
# assert profile.product_name is None
# assert profile.product_info is None