bpo-42328: Fix tkinter.ttk.Style.map(). (GH-23300)

The function accepts now the representation of the default state as
empty sequence (as returned by Style.map()).
The structure of the result is now the same on all platform
and does not depend on the value of wantobjects.
This commit is contained in:
Serhiy Storchaka 2020-11-22 22:48:52 +02:00 committed by GitHub
parent 313467efdc
commit dd844a2916
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 111 additions and 28 deletions

View file

@ -137,6 +137,9 @@ def test_format_mapdict(self):
result = ttk._format_mapdict(opts)
self.assertEqual(result, ('-üñíćódè', 'á vãl'))
self.assertEqual(ttk._format_mapdict({'opt': [('value',)]}),
('-opt', '{} value'))
# empty states
valid = {'opt': [('', '', 'hi')]}
self.assertEqual(ttk._format_mapdict(valid), ('-opt', '{ } hi'))
@ -159,10 +162,6 @@ def test_format_mapdict(self):
opts = {'a': None}
self.assertRaises(TypeError, ttk._format_mapdict, opts)
# items in the value must have size >= 2
self.assertRaises(IndexError, ttk._format_mapdict,
{'a': [('invalid', )]})
def test_format_elemcreate(self):
self.assertTrue(ttk._format_elemcreate(None), (None, ()))