Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-120873: Add test for "state" option in ttk.Scale
Also refactor the "state" option tests for other ttk widgets.
  • Loading branch information
serhiy-storchaka committed Jun 22, 2024
commit 89426e656ca1a51c42ae3826db735be74de0152c
22 changes: 10 additions & 12 deletions Lib/test/test_ttk/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
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)

Expand Down Expand Up @@ -44,6 +45,10 @@ def padding_conv(value):
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'], '')
Expand Down Expand Up @@ -183,10 +188,6 @@ def test_configure_compound(self):
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)
Expand Down Expand Up @@ -359,11 +360,6 @@ def test_configure_show(self):
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',
Expand Down Expand Up @@ -803,7 +799,7 @@ def test_configure_menu(self):
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'
Expand All @@ -825,6 +821,8 @@ def test_configure_length(self):
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)
Expand Down