Skip to content

Commit

Permalink
pythongh-120873: Add test for "state" option in ttk.Scale (pythonGH-1…
Browse files Browse the repository at this point in the history
…20874)

Also refactor the "state" option tests for other ttk widgets.
  • Loading branch information
serhiy-storchaka authored Jun 22, 2024
1 parent 879d1f2 commit 974a978
Showing 1 changed file with 10 additions and 12 deletions.
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

0 comments on commit 974a978

Please sign in to comment.