diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-12-26 12:27:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-26 12:27:29 (GMT) |
commit | aa056ed472e9d0a79ea21784f6f5171d12a13f85 (patch) | |
tree | e12abc6bae8f53e6da592eb9d6acf2a82a7b8df3 /Lib/tkinter/test/test_tkinter/test_misc.py | |
parent | 25a12aac4de819745dfc64664ba183a5784b5a81 (diff) | |
download | cpython-aa056ed472e9d0a79ea21784f6f5171d12a13f85.zip cpython-aa056ed472e9d0a79ea21784f6f5171d12a13f85.tar.gz cpython-aa056ed472e9d0a79ea21784f6f5171d12a13f85.tar.bz2 |
bpo-45496: Allow flexibility in winfo_rgb tests (GH-30185)
(cherry picked from commit 2e3e0d23adca8d83722d939d6abd1e467d7578f7)
Co-authored-by: E-Paine <63801254+E-Paine@users.noreply.github.com>
Diffstat (limited to 'Lib/tkinter/test/test_tkinter/test_misc.py')
-rw-r--r-- | Lib/tkinter/test/test_tkinter/test_misc.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/tkinter/test/test_tkinter/test_misc.py b/Lib/tkinter/test/test_tkinter/test_misc.py index 554ae74..43ffd46 100644 --- a/Lib/tkinter/test/test_tkinter/test_misc.py +++ b/Lib/tkinter/test/test_tkinter/test_misc.py @@ -193,6 +193,13 @@ class MiscTest(AbstractTkTest, unittest.TestCase): root.clipboard_get() def test_winfo_rgb(self): + + def assertApprox(col1, col2): + # A small amount of flexibility is required (bpo-45496) + # 33 is ~0.05% of 65535, which is a reasonable margin + for col1_channel, col2_channel in zip(col1, col2): + self.assertAlmostEqual(col1_channel, col2_channel, delta=33) + root = self.root rgb = root.winfo_rgb @@ -202,9 +209,9 @@ class MiscTest(AbstractTkTest, unittest.TestCase): # #RGB - extends each 4-bit hex value to be 16-bit. self.assertEqual(rgb('#F0F'), (0xFFFF, 0x0000, 0xFFFF)) # #RRGGBB - extends each 8-bit hex value to be 16-bit. - self.assertEqual(rgb('#4a3c8c'), (0x4a4a, 0x3c3c, 0x8c8c)) + assertApprox(rgb('#4a3c8c'), (0x4a4a, 0x3c3c, 0x8c8c)) # #RRRRGGGGBBBB - self.assertEqual(rgb('#dede14143939'), (0xdede, 0x1414, 0x3939)) + assertApprox(rgb('#dede14143939'), (0xdede, 0x1414, 0x3939)) # Invalid string. with self.assertRaises(tkinter.TclError): rgb('#123456789a') |