Skip to content

Commit 46cb5fd

Browse files
[2.7] bpo-34189: Add simple tests for new Tk widget options. (GH-8396). (GH-8400)
(cherry picked from commit e271ca7) (cherry picked from commit c75c1e0)
1 parent 041a4ee commit 46cb5fd

3 files changed

Lines changed: 1263 additions & 3 deletions

File tree

Lib/lib-tk/test/test_tkinter/test_widgets.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ class ListboxTest(AbstractWidgetTest, unittest.TestCase):
700700
'disabledforeground', 'exportselection',
701701
'font', 'foreground', 'height',
702702
'highlightbackground', 'highlightcolor', 'highlightthickness',
703-
'listvariable', 'relief',
703+
'justify', 'listvariable', 'relief',
704704
'selectbackground', 'selectborderwidth', 'selectforeground',
705705
'selectmode', 'setgrid', 'state',
706706
'takefocus', 'width', 'xscrollcommand', 'yscrollcommand',
@@ -714,6 +714,8 @@ def test_activestyle(self):
714714
self.checkEnumParam(widget, 'activestyle',
715715
'dotbox', 'none', 'underline')
716716

717+
test_justify = requires_tcl(8, 6, 5)(StandardOptionsTests.test_justify.im_func)
718+
717719
def test_listvariable(self):
718720
widget = self.create()
719721
var = tkinter.DoubleVar(self.root)
@@ -947,7 +949,9 @@ class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
947949
OPTIONS = (
948950
'background', 'borderwidth', 'cursor',
949951
'handlepad', 'handlesize', 'height',
950-
'opaqueresize', 'orient', 'relief',
952+
'opaqueresize', 'orient',
953+
'proxybackground', 'proxyborderwidth', 'proxyrelief',
954+
'relief',
951955
'sashcursor', 'sashpad', 'sashrelief', 'sashwidth',
952956
'showhandle', 'width',
953957
)
@@ -974,6 +978,23 @@ def test_opaqueresize(self):
974978
widget = self.create()
975979
self.checkBooleanParam(widget, 'opaqueresize')
976980

981+
@requires_tcl(8, 6, 5)
982+
def test_proxybackground(self):
983+
widget = self.create()
984+
self.checkColorParam(widget, 'proxybackground')
985+
986+
@requires_tcl(8, 6, 5)
987+
def test_proxyborderwidth(self):
988+
widget = self.create()
989+
self.checkPixelsParam(widget, 'proxyborderwidth',
990+
0, 1.3, 2.9, 6, -2, '10p',
991+
conv=noconv)
992+
993+
@requires_tcl(8, 6, 5)
994+
def test_proxyrelief(self):
995+
widget = self.create()
996+
self.checkReliefParam(widget, 'proxyrelief')
997+
977998
def test_sashcursor(self):
978999
widget = self.create()
9791000
self.checkCursorParam(widget, 'sashcursor')

Lib/lib-tk/test/test_ttk/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 unittest
34
import Tkinter as tkinter
@@ -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

0 commit comments

Comments
 (0)