@@ -201,6 +201,13 @@ def test_clipboard_astral(self):
201201 root .clipboard_get ()
202202
203203 def test_winfo_rgb (self ):
204+
205+ def assertApprox (col1 , col2 ):
206+ # A small amount of flexibility is required (bpo-45496)
207+ # 33 is ~0.05% of 65535, which is a reasonable margin
208+ for col1_channel , col2_channel in zip (col1 , col2 ):
209+ self .assertAlmostEqual (col1_channel , col2_channel , delta = 33 )
210+
204211 root = self .root
205212 rgb = root .winfo_rgb
206213
@@ -210,9 +217,9 @@ def test_winfo_rgb(self):
210217 # #RGB - extends each 4-bit hex value to be 16-bit.
211218 self .assertEqual (rgb ('#F0F' ), (0xFFFF , 0x0000 , 0xFFFF ))
212219 # #RRGGBB - extends each 8-bit hex value to be 16-bit.
213- self . assertEqual (rgb ('#4a3c8c' ), (0x4a4a , 0x3c3c , 0x8c8c ))
220+ assertApprox (rgb ('#4a3c8c' ), (0x4a4a , 0x3c3c , 0x8c8c ))
214221 # #RRRRGGGGBBBB
215- self . assertEqual (rgb ('#dede14143939' ), (0xdede , 0x1414 , 0x3939 ))
222+ assertApprox (rgb ('#dede14143939' ), (0xdede , 0x1414 , 0x3939 ))
216223 # Invalid string.
217224 with self .assertRaises (tkinter .TclError ):
218225 rgb ('#123456789a' )
0 commit comments