diff --git a/Tests/test_imagecms_init.py b/Tests/test_imagecms_init.py new file mode 100644 index 000000000..2f4fc8d00 --- /dev/null +++ b/Tests/test_imagecms_init.py @@ -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 \ No newline at end of file