-
-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[3.9] bpo-33289: Return RGB triplet of ints instead of floats from tk…
…inter.colorchooser (GH-6578). (GH-24318) (cherry picked from commit 6713e86) Co-authored-by: Cheryl Sabella <cheryl.sabella@gmail.com> (cherry picked from commit 3d5434d) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
- Loading branch information
1 parent
63ebba0
commit 96bcf6f
Showing
5 changed files
with
102 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import unittest | ||
import tkinter | ||
from test.support import requires, run_unittest, swap_attr | ||
from tkinter.test.support import AbstractTkTest | ||
from tkinter import colorchooser | ||
|
||
requires('gui') | ||
|
||
|
||
class ChooserTest(AbstractTkTest, unittest.TestCase): | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
AbstractTkTest.setUpClass.__func__(cls) | ||
cls.cc = colorchooser.Chooser(initialcolor='dark blue slate') | ||
|
||
def test_fixoptions(self): | ||
cc = self.cc | ||
cc._fixoptions() | ||
self.assertEqual(cc.options['initialcolor'], 'dark blue slate') | ||
|
||
cc.options['initialcolor'] = '#D2D269691E1E' | ||
cc._fixoptions() | ||
self.assertEqual(cc.options['initialcolor'], '#D2D269691E1E') | ||
|
||
cc.options['initialcolor'] = (210, 105, 30) | ||
cc._fixoptions() | ||
self.assertEqual(cc.options['initialcolor'], '#d2691e') | ||
|
||
def test_fixresult(self): | ||
cc = self.cc | ||
self.assertEqual(cc._fixresult(self.root, ()), (None, None)) | ||
self.assertEqual(cc._fixresult(self.root, ''), (None, None)) | ||
self.assertEqual(cc._fixresult(self.root, 'chocolate'), | ||
((210, 105, 30), 'chocolate')) | ||
self.assertEqual(cc._fixresult(self.root, '#4a3c8c'), | ||
((74, 60, 140), '#4a3c8c')) | ||
|
||
|
||
tests_gui = (ChooserTest,) | ||
|
||
if __name__ == "__main__": | ||
run_unittest(*tests_gui) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
Misc/NEWS.d/next/Library/2018-04-23-13-44-10.bpo-33289.anBnUr.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Correct call to :mod:`tkinter.colorchooser` to return RGB triplet of ints | ||
instead of floats. Patch by Cheryl Sabella. |