@@ -72,3 +72,24 @@ def test_not_equal(mode):
72
72
img_b = Image .frombytes (mode , (2 , 2 ), data_b )
73
73
assert img_a .tobytes () != img_b .tobytes ()
74
74
assert img_a .im != img_b .im
75
+
76
+
77
+ @pytest .mark .parametrize ("mode" , ("RGB" , "YCbCr" , "HSV" , "LAB" ))
78
+ def test_equal_three_channels_four_bytes (mode ):
79
+ # The "A" and "B" values in LAB images are signed values from -128 to 127,
80
+ # but we store them as unsigned values from 0 to 255, so we need to use
81
+ # slightly different input bytes for LAB to get the same output.
82
+ img_a = Image .new (mode , (1 , 1 ), 0x00B3B231 if mode == "LAB" else 0x00333231 )
83
+ img_b = Image .new (mode , (1 , 1 ), 0xFFB3B231 if mode == "LAB" else 0xFF333231 )
84
+ assert img_a .tobytes () == b"123"
85
+ assert img_b .tobytes () == b"123"
86
+ assert img_a .im == img_b .im
87
+
88
+
89
+ @pytest .mark .parametrize ("mode" , ("LA" , "La" , "PA" ))
90
+ def test_equal_two_channels_four_bytes (mode ):
91
+ img_a = Image .new (mode , (1 , 1 ), 0x32000031 )
92
+ img_b = Image .new (mode , (1 , 1 ), 0x32FFFF31 )
93
+ assert img_a .tobytes () == b"12"
94
+ assert img_b .tobytes () == b"12"
95
+ assert img_a .im == img_b .im
0 commit comments