Skip to content

Commit c7b91d9

Browse files
[3.7] bpo-34189: Add simple tests for new Tk widget options. (GH-8396) (GH-8398)
(cherry picked from commit e271ca7) (cherry picked from commit c75c1e0)
1 parent 81f85d0 commit c7b91d9

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

Lib/tkinter/test/support.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import functools
12
import re
23
import tkinter
34
import unittest
@@ -54,9 +55,20 @@ def simulate_mouse_click(widget, x, y):
5455
tcl_version = tuple(map(int, _tkinter.TCL_VERSION.split('.')))
5556

5657
def requires_tcl(*version):
57-
return unittest.skipUnless(tcl_version >= version,
58+
if len(version) <= 2:
59+
return unittest.skipUnless(tcl_version >= version,
5860
'requires Tcl version >= ' + '.'.join(map(str, version)))
5961

62+
def deco(test):
63+
@functools.wraps(test)
64+
def newtest(self):
65+
if get_tk_patchlevel() < (8, 6, 5):
66+
self.skipTest('requires Tcl version >= ' +
67+
'.'.join(map(str, get_tk_patchlevel())))
68+
test(self)
69+
return newtest
70+
return deco
71+
6072
_tk_patchlevel = None
6173
def get_tk_patchlevel():
6274
global _tk_patchlevel

Lib/tkinter/test/test_tkinter/test_widgets.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ class ListboxTest(AbstractWidgetTest, unittest.TestCase):
703703
'disabledforeground', 'exportselection',
704704
'font', 'foreground', 'height',
705705
'highlightbackground', 'highlightcolor', 'highlightthickness',
706-
'listvariable', 'relief',
706+
'justify', 'listvariable', 'relief',
707707
'selectbackground', 'selectborderwidth', 'selectforeground',
708708
'selectmode', 'setgrid', 'state',
709709
'takefocus', 'width', 'xscrollcommand', 'yscrollcommand',
@@ -717,6 +717,8 @@ def test_activestyle(self):
717717
self.checkEnumParam(widget, 'activestyle',
718718
'dotbox', 'none', 'underline')
719719

720+
test_justify = requires_tcl(8, 6, 5)(StandardOptionsTests.test_justify)
721+
720722
def test_listvariable(self):
721723
widget = self.create()
722724
var = tkinter.DoubleVar(self.root)
@@ -951,7 +953,9 @@ class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
951953
OPTIONS = (
952954
'background', 'borderwidth', 'cursor',
953955
'handlepad', 'handlesize', 'height',
954-
'opaqueresize', 'orient', 'relief',
956+
'opaqueresize', 'orient',
957+
'proxybackground', 'proxyborderwidth', 'proxyrelief',
958+
'relief',
955959
'sashcursor', 'sashpad', 'sashrelief', 'sashwidth',
956960
'showhandle', 'width',
957961
)
@@ -978,6 +982,23 @@ def test_opaqueresize(self):
978982
widget = self.create()
979983
self.checkBooleanParam(widget, 'opaqueresize')
980984

985+
@requires_tcl(8, 6, 5)
986+
def test_proxybackground(self):
987+
widget = self.create()
988+
self.checkColorParam(widget, 'proxybackground')
989+
990+
@requires_tcl(8, 6, 5)
991+
def test_proxyborderwidth(self):
992+
widget = self.create()
993+
self.checkPixelsParam(widget, 'proxyborderwidth',
994+
0, 1.3, 2.9, 6, -2, '10p',
995+
conv=noconv)
996+
997+
@requires_tcl(8, 6, 5)
998+
def test_proxyrelief(self):
999+
widget = self.create()
1000+
self.checkReliefParam(widget, 'proxyrelief')
1001+
9811002
def test_sashcursor(self):
9821003
widget = self.create()
9831004
self.checkCursorParam(widget, 'sashcursor')

0 commit comments

Comments
 (0)