]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-120873: Add test for "state" option in ttk.Scale (GH-120874)
authorSerhiy Storchaka <storchaka@gmail.com>
Sat, 22 Jun 2024 11:18:04 +0000 (14:18 +0300)
committerGitHub <noreply@github.com>
Sat, 22 Jun 2024 11:18:04 +0000 (11:18 +0000)
Also refactor the "state" option tests for other ttk widgets.

Lib/test/test_ttk/test_widgets.py

index 2eb2c4463665171ee00d9fe9c13609c51ecdb06d..0c8931b384c6c993b52f5df4dc7602c401896424 100644 (file)
@@ -5,8 +5,9 @@ from test.support import requires, gc_collect
 import sys
 
 from test.test_ttk_textonly import MockTclObj
-from test.test_tkinter.support import (AbstractTkTest, tk_version, get_tk_patchlevel,
-                                  simulate_mouse_click, AbstractDefaultRootTest)
+from test.test_tkinter.support import (
+    AbstractTkTest, requires_tk, tk_version, get_tk_patchlevel,
+    simulate_mouse_click, AbstractDefaultRootTest)
 from test.test_tkinter.widget_tests import (add_standard_options,
     AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests)
 
@@ -44,6 +45,10 @@ class StandardTtkOptionsTests(StandardOptionsTests):
         self.checkParam(widget, 'padding', ('5p', '6p', '7p', '8p'))
         self.checkParam(widget, 'padding', (), expected='')
 
+    def test_configure_state(self):
+        widget = self.create()
+        self.checkParams(widget, 'state', 'active', 'disabled', 'readonly')
+
     def test_configure_style(self):
         widget = self.create()
         self.assertEqual(widget['style'], '')
@@ -183,10 +188,6 @@ class AbstractLabelTest(AbstractWidgetTest):
         widget = self.create()
         self.checkEnumParam(widget, 'compound', *values, allow_empty=True)
 
-    def test_configure_state(self):
-        widget = self.create()
-        self.checkParams(widget, 'state', 'active', 'disabled', 'normal')
-
     def test_configure_width(self):
         widget = self.create()
         self.checkParams(widget, 'width', 402, -402, 0)
@@ -359,11 +360,6 @@ class EntryTest(AbstractWidgetTest, unittest.TestCase):
         self.checkParam(widget, 'show', '')
         self.checkParam(widget, 'show', ' ')
 
-    def test_configure_state(self):
-        widget = self.create()
-        self.checkParams(widget, 'state',
-                         'disabled', 'normal', 'readonly')
-
     def test_configure_validate(self):
         widget = self.create()
         self.checkEnumParam(widget, 'validate',
@@ -803,7 +799,7 @@ class MenubuttonTest(AbstractLabelTest, unittest.TestCase):
 class ScaleTest(AbstractWidgetTest, unittest.TestCase):
     OPTIONS = (
         'class', 'command', 'cursor', 'from', 'length',
-        'orient', 'style', 'takefocus', 'to', 'value', 'variable',
+        'orient', 'state', 'style', 'takefocus', 'to', 'value', 'variable',
     )
     _conv_pixels = False
     default_orient = 'horizontal'
@@ -825,6 +821,8 @@ class ScaleTest(AbstractWidgetTest, unittest.TestCase):
         widget = self.create()
         self.checkPixelsParam(widget, 'length', 130, 131.2, 135.6, '5i')
 
+    test_configure_state = requires_tk(8, 6, 9)(StandardTtkOptionsTests.test_configure_state)
+
     def test_configure_to(self):
         widget = self.create()
         self.checkFloatParam(widget, 'to', 300, 14.9, 15.1, -10, conv=False)