Skip to content

Commit cbae3d4

Browse files
miss-islingtonzware
authored andcommitted
bpo-45436: Fix tkinter tests with Tcl/Tk 8.6.11+ (pythonGH-29077) (pythonGH-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 04a2362 commit cbae3d4

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
@@ -1166,8 +1166,11 @@ def test_title(self):
11661166

11671167
def test_type(self):
11681168
widget = self.create()
1169-
self.checkEnumParam(widget, 'type',
1170-
'normal', 'tearoff', 'menubar')
1169+
self.checkEnumParam(
1170+
widget, 'type',
1171+
'normal', 'tearoff', 'menubar',
1172+
errmsg='bad type "{}": must be normal, tearoff, or menubar',
1173+
)
11711174

11721175
def test_entryconfigure(self):
11731176
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
@@ -170,10 +170,13 @@ def checkImageParam(self, widget, name):
170170
errmsg='image "spam" doesn\'t exist')
171171

172172
def test_compound(self):
173+
options = 'none text image center top bottom left right'.split()
174+
errmsg = (
175+
'bad compound "{}": must be'
176+
f' {", ".join(options[:-1])}, or {options[-1]}'
177+
)
173178
widget = self.create()
174-
self.checkEnumParam(widget, 'compound',
175-
'none', 'text', 'image', 'center',
176-
'top', 'bottom', 'left', 'right')
179+
self.checkEnumParam(widget, 'compound', *options, errmsg=errmsg)
177180

178181
def test_state(self):
179182
widget = self.create()

0 commit comments

Comments
 (0)