Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Polishing.
  • Loading branch information
serhiy-storchaka committed Jun 22, 2024
commit 28e9c3544eb2789ae561c75578bbfc24bae9dc22
7 changes: 2 additions & 5 deletions Lib/test/test_tkinter/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ class AbstractLabelTest(AbstractWidgetTest, IntegerSizeTests):
_clip_pad = tk_version >= (8, 7)
_clip_borderwidth = tk_version >= (8, 7)

test_configure_justify = requires_tk(8, 7)(StandardOptionsTests.test_configure_justify)

@add_standard_options(StandardOptionsTests)
class LabelTest(AbstractLabelTest, unittest.TestCase):
Expand Down Expand Up @@ -1178,10 +1177,6 @@ class ScrollbarTest(AbstractWidgetTest, unittest.TestCase):
def create(self, **kwargs):
return tkinter.Scrollbar(self.root, **kwargs)

def test_configure_activerelief(self):
widget = self.create()
self.checkReliefParam(widget, 'activerelief')

def test_configure_elementborderwidth(self):
widget = self.create()
self.checkPixelsParam(widget, 'elementborderwidth', 4.3, 5.6, '1m')
Expand Down Expand Up @@ -1404,6 +1399,8 @@ def test_indexcommand_none(self):
i = widget.index('none')
self.assertIsNone(i)

test_configure_activerelief = requires_tk(8, 7)(StandardOptionsTests.test_configure_activerelief)

def test_configure_postcommand(self):
widget = self.create()
self.checkCommandParam(widget, 'postcommand')
Expand Down
13 changes: 9 additions & 4 deletions Lib/test/test_tkinter/widget_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class AbstractWidgetTest(AbstractTkTest):
_clip_highlightthickness = True
_clip_pad = False
_clip_borderwidth = False
_allow_empty_justify = False

@property
def scaling(self):
Expand Down Expand Up @@ -243,7 +244,6 @@ def test_configure_activeforeground(self):
widget = self.create()
self.checkColorParam(widget, 'activeforeground')

@requires_tk(8, 7)
def test_configure_activerelief(self):
widget = self.create()
self.checkReliefParam(widget, 'activerelief')
Expand Down Expand Up @@ -310,8 +310,10 @@ def test_configure_font(self):
widget = self.create()
self.checkParam(widget, 'font',
'-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*')
self.checkInvalidParam(widget, 'font', '',
errmsg='font "" doesn\'t exist')
is_ttk = widget.__class__.__module__ == 'tkinter.ttk'
if not is_ttk:
self.checkInvalidParam(widget, 'font', '',
errmsg='font "" doesn\'t exist')

def test_configure_foreground(self):
widget = self.create()
Expand Down Expand Up @@ -366,7 +368,10 @@ def test_configure_jump(self):

def test_configure_justify(self):
widget = self.create()
self.checkEnumParam(widget, 'justify', 'left', 'right', 'center',
values = ('left', 'right', 'center')
if self._allow_empty_justify:
values += ('',)
self.checkEnumParam(widget, 'justify', *values,
fullname='justification')

def test_configure_orient(self):
Expand Down
40 changes: 7 additions & 33 deletions Lib/test/test_ttk/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def test_configure_labelwidget(self):


class AbstractLabelTest(AbstractWidgetTest):
_allow_empty_justify = True

def checkImageParam(self, widget, name):
image = tkinter.PhotoImage(master=self.root, name='image1')
Expand All @@ -188,14 +189,7 @@ def test_configure_compound(self):
widget = self.create()
self.checkEnumParam(widget, 'compound', *values, allow_empty=True)

@requires_tk(8, 7)
def test_configure_justify(self):
widget = self.create()
values = ('left', 'right', 'center')
if tk_version >= (8, 7):
values += ('',)
self.checkEnumParam(widget, 'justify', *values,
fullname='justification')
test_configure_justify = requires_tk(8, 7)(StandardOptionsTests.test_configure_justify)

def test_configure_width(self):
widget = self.create()
Expand All @@ -212,22 +206,12 @@ class LabelTest(AbstractLabelTest, unittest.TestCase):
'underline', 'width', 'wraplength',
)
_conv_pixels = False
_allow_empty_justify = tk_version >= (8, 7)

def create(self, **kwargs):
return ttk.Label(self.root, **kwargs)

def test_configure_justify(self):
widget = self.create()
values = ('left', 'right', 'center')
if tk_version >= (8, 7):
values += ('',)
self.checkEnumParam(widget, 'justify', *values,
fullname='justification')

def test_configure_font(self):
widget = self.create()
self.checkParam(widget, 'font',
'-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*')
test_configure_justify = StandardOptionsTests.test_configure_justify


@add_standard_options(StandardTtkOptionsTests)
Expand Down Expand Up @@ -924,6 +908,7 @@ class ProgressbarTest(AbstractWidgetTest, unittest.TestCase):
'style', 'takefocus', 'value', 'variable',
)
_conv_pixels = False
_allow_empty_justify = True
default_orient = 'horizontal'

def create(self, **kwargs):
Expand All @@ -935,20 +920,9 @@ def test_configure_anchor(self):
self.checkEnumParam(widget, 'anchor',
'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw', 'center', '')

@requires_tk(8, 7)
def test_configure_font(self):
widget = self.create()
self.checkParam(widget, 'font',
'-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*')

test_configure_font = requires_tk(8, 7)(StandardOptionsTests.test_configure_font)
test_configure_foreground = requires_tk(8, 7)(StandardOptionsTests.test_configure_foreground)

@requires_tk(8, 7)
def test_configure_justify(self):
widget = self.create()
values = ('left', 'right', 'center', '')
self.checkEnumParam(widget, 'justify', *values,
fullname='justification')
test_configure_justify = requires_tk(8, 7)(StandardTtkOptionsTests.test_configure_justify)

def test_configure_length(self):
widget = self.create()
Expand Down