gh-120873: Add test for "state" option in ttk.Scale (GH-120874)

Also refactor the "state" option tests for other ttk widgets.
This commit is contained in:
Serhiy Storchaka 2024-06-22 14:18:04 +03:00 committed by GitHub
parent 879d1f28bb
commit 974a978631
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 12 deletions

View 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)