Skip to content

Commit 530eec3

Browse files
Strengthen the test_background test.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 3a8c808 commit 530eec3

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎Lib/test/test_tkinter/test_simpledialog.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,18 @@ def test_use_classic(self):
276276
self.assertTrue(invoked)
277277

278278
def test_background(self):
279+
# The ttk dialog adopts the ttk background, even a customized one,
280+
# while the classic dialog keeps the default Toplevel background.
281+
style = ttk.Style(self.root)
282+
old = style.lookup('.', 'background')
283+
style.configure('.', background='#123456')
284+
self.addCleanup(style.configure, '.', background=old)
279285
d = self.open()
280-
self.assertEqual(str(d.cget('background')),
281-
ttk.Style(d).lookup('.', 'background'))
286+
self.assertEqual(str(d.cget('background')), '#123456')
287+
d = self.open(use_ttk=False)
288+
ref = tkinter.Toplevel(self.root)
289+
self.addCleanup(ref.destroy)
290+
self.assertEqual(str(d.cget('background')), str(ref.cget('background')))
282291

283292
def test_base_classic_by_default(self):
284293
# The Dialog base defaults to classic widgets so that subclasses adding

0 commit comments

Comments
 (0)