@@ -162,14 +162,23 @@ def test_winfo_rgb(self):
162
162
163
163
# Color name.
164
164
self .assertEqual (rgb ('red' ), (65535 , 0 , 0 ))
165
- # #RGB
166
- self .assertEqual (rgb ('#f00' ), (65535 , 0 , 0 ))
167
- # #RRGGBB
168
- self .assertEqual (rgb ('#ff0000' ), (65535 , 0 , 0 ))
169
- # #RRRGGGBBB
170
- self .assertEqual (rgb ('#000fff000' ), (0 , 65535 , 0 ))
171
- # #RRRRGGGGBBBB
172
- self .assertEqual (rgb ('#ffff0000ffff' ), (65535 , 0 , 65535 ))
165
+ self .assertEqual (rgb ('dark slate blue' ), (18504 , 15677 , 35723 ))
166
+ # #RGB - extends each 4-bit hex value to be 16-bit.
167
+ self .assertEqual (rgb ('#f00' ),
168
+ (int ('ffff' , 16 ), 0 , 0 ))
169
+ # #RRGGBB - extends each 8-bit hex value to be 16-bit.
170
+ self .assertTrue (rgb ('#483d8b' ) ==
171
+ (int ('4848' , 16 ), int ('3d3d' , 16 ), int ('8b8b' , 16 )) ==
172
+ (18504 , 15677 , 35723 )) # dark slate blue
173
+ # #RRRGGGBBB - uses 2 highest order bits for each color.
174
+ self .assertEqual (rgb ('#123456789' ),
175
+ (int ('1212' , 16 ), int ('4545' , 16 ), int ('7878' , 16 )))
176
+ # #RRRRGGGGBBBB - uses 2 highest order bits for each color.
177
+ self .assertEqual (rgb ('#1234567800ff' ),
178
+ (int ('1212' , 16 ), int ('5656' , 16 ), int ('0000' , 16 )))
179
+ # Invalid string.
180
+ with self .assertRaises (tkinter .TclError ):
181
+ rgb ('#1234567890' )
173
182
# RGB triplet is invalid input.
174
183
with self .assertRaises (tkinter .TclError ):
175
184
rgb ((255 , 0 , 0 ))
0 commit comments