Skip to content

Commit 2ce3816

Browse files
bpo-45436: Fix tkinter tests with Tcl/Tk 8.6.11+ (GH-29077) (GH-29093)
Since v8.6.11, a few configuration options seem to accept an empty value where they did not previously; particularly the `type` of a `Menu` widget, and the `compound` of any ttk widget with a label. Providing an explicit expected error message to `checkEnumParam` bypasses the check of an empty value, which no longer raises `TclError`. (cherry picked from commit 4fe454c) Co-authored-by: Zachary Ware <[email protected]>
1 parent 67e10be commit 2ce3816

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Lib/tkinter/test/test_tkinter/test_widgets.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,8 +1244,11 @@ def test_configure_title(self):
12441244

12451245
def test_configure_type(self):
12461246
widget = self.create()
1247-
self.checkEnumParam(widget, 'type',
1248-
'normal', 'tearoff', 'menubar')
1247+
self.checkEnumParam(
1248+
widget, 'type',
1249+
'normal', 'tearoff', 'menubar',
1250+
errmsg='bad type "{}": must be normal, tearoff, or menubar',
1251+
)
12491252

12501253
def test_entryconfigure(self):
12511254
m1 = self.create()

Lib/tkinter/test/test_ttk/test_widgets.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,13 @@ def checkImageParam(self, widget, name):
169169
errmsg='image "spam" doesn\'t exist')
170170

171171
def test_configure_compound(self):
172+
options = 'none text image center top bottom left right'.split()
173+
errmsg = (
174+
'bad compound "{}": must be'
175+
f' {", ".join(options[:-1])}, or {options[-1]}'
176+
)
172177
widget = self.create()
173-
self.checkEnumParam(widget, 'compound',
174-
'none', 'text', 'image', 'center',
175-
'top', 'bottom', 'left', 'right')
178+
self.checkEnumParam(widget, 'compound', *options, errmsg=errmsg)
176179

177180
def test_configure_state(self):
178181
widget = self.create()

0 commit comments

Comments
 (0)