@@ -193,6 +193,13 @@ def test_clipboard_astral(self):
193193 root .clipboard_get ()
194194
195195 def test_winfo_rgb (self ):
196+
197+ def assertApprox (col1 , col2 ):
198+ # A small amount of flexibility is required (bpo-45496)
199+ # 33 is ~0.05% of 65535, which is a reasonable margin
200+ for col1_channel , col2_channel in zip (col1 , col2 ):
201+ self .assertAlmostEqual (col1_channel , col2_channel , delta = 33 )
202+
196203 root = self .root
197204 rgb = root .winfo_rgb
198205
@@ -202,9 +209,9 @@ def test_winfo_rgb(self):
202209 # #RGB - extends each 4-bit hex value to be 16-bit.
203210 self .assertEqual (rgb ('#F0F' ), (0xFFFF , 0x0000 , 0xFFFF ))
204211 # #RRGGBB - extends each 8-bit hex value to be 16-bit.
205- self . assertEqual (rgb ('#4a3c8c' ), (0x4a4a , 0x3c3c , 0x8c8c ))
212+ assertApprox (rgb ('#4a3c8c' ), (0x4a4a , 0x3c3c , 0x8c8c ))
206213 # #RRRRGGGGBBBB
207- self . assertEqual (rgb ('#dede14143939' ), (0xdede , 0x1414 , 0x3939 ))
214+ assertApprox (rgb ('#dede14143939' ), (0xdede , 0x1414 , 0x3939 ))
208215 # Invalid string.
209216 with self .assertRaises (tkinter .TclError ):
210217 rgb ('#123456789a' )
0 commit comments