bpo-45436: Fix tkinter tests with Tcl/Tk 8.6.11+ (GH-29077) (GH-29081)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 20 Oct 2021 13:50:31 +0000 (06:50 -0700)
committerSean Whitton <spwhitton@spwhitton.name>
Thu, 20 Mar 2025 02:07:39 +0000 (10:07 +0800)
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 4fe454c6f54b0948af67b53af6c2f35af6377e69)

Co-authored-by: Zachary Ware <zach@python.org>
Gbp-Pq: Name 0030-bpo-45436-Fix-tkinter-tests-with-Tcl-Tk-8.6.11-GH-29.patch

Lib/tkinter/test/test_tkinter/test_widgets.py
Lib/tkinter/test/test_ttk/test_widgets.py

index 39334de8cf41c3caba0f1f0e0ba4267aeeb31e1d..cc227e579679b739d7a8c14167c64b57427021ae 100644 (file)
@@ -1241,8 +1241,11 @@ class MenuTest(AbstractWidgetTest, unittest.TestCase):
 
     def test_configure_type(self):
         widget = self.create()
-        self.checkEnumParam(widget, 'type',
-                'normal', 'tearoff', 'menubar')
+        self.checkEnumParam(
+            widget, 'type',
+            'normal', 'tearoff', 'menubar',
+            errmsg='bad type "{}": must be normal, tearoff, or menubar',
+            )
 
     def test_entryconfigure(self):
         m1 = self.create()
index 1fac83a004a6d0e441c289dcec070120237bb5dd..88a800d05e4cacc8bb3f43797f5ee80c9ecf1fcb 100644 (file)
@@ -169,10 +169,13 @@ class AbstractLabelTest(AbstractWidgetTest):
                 errmsg='image "spam" doesn\'t exist')
 
     def test_configure_compound(self):
+        options = 'none text image center top bottom left right'.split()
+        errmsg = (
+            'bad compound "{}": must be'
+            f' {", ".join(options[:-1])}, or {options[-1]}'
+            )
         widget = self.create()
-        self.checkEnumParam(widget, 'compound',
-                'none', 'text', 'image', 'center',
-                'top', 'bottom', 'left', 'right')
+        self.checkEnumParam(widget, 'compound', *options, errmsg=errmsg)
 
     def test_configure_state(self):
         widget = self.create()