summaryrefslogtreecommitdiffstats
path: root/Lib/lib-tk/test
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-11-09 19:15:26 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-11-09 19:15:26 (GMT)
commitf87854e7bfe3ef18469909ba968e3474fe31646d (patch)
treef83c2813e49432a363ad59e462335303118bd3d8 /Lib/lib-tk/test
parentb8147452265077d4c12464a9943903f0d040f79c (diff)
downloadcpython-f87854e7bfe3ef18469909ba968e3474fe31646d.zip
cpython-f87854e7bfe3ef18469909ba968e3474fe31646d.tar.gz
cpython-f87854e7bfe3ef18469909ba968e3474fe31646d.tar.bz2
Fix Tkinter tests on Tk 8.5 with patchlevel < 8.5.11 (issue #19085).
Diffstat (limited to 'Lib/lib-tk/test')
-rw-r--r--Lib/lib-tk/test/test_tkinter/test_widgets.py11
-rw-r--r--Lib/lib-tk/test/test_ttk/support.py15
-rw-r--r--Lib/lib-tk/test/widget_tests.py27
3 files changed, 31 insertions, 22 deletions
diff --git a/Lib/lib-tk/test/test_tkinter/test_widgets.py b/Lib/lib-tk/test/test_tkinter/test_widgets.py
index 2808313..f962b82 100644
--- a/Lib/lib-tk/test/test_tkinter/test_widgets.py
+++ b/Lib/lib-tk/test/test_tkinter/test_widgets.py
@@ -3,7 +3,8 @@ import Tkinter
import os
from test.test_support import requires, run_unittest
-from test_ttk.support import tcl_version, requires_tcl, widget_eq
+from test_ttk.support import (tcl_version, requires_tcl, get_tk_patchlevel,
+ widget_eq)
from widget_tests import (
add_standard_options, noconv, noconv_meth, int_round, pixels_round,
AbstractWidgetTest, StandardOptionsTests,
@@ -536,7 +537,7 @@ class TextTest(AbstractWidgetTest, unittest.TestCase):
def test_selectborderwidth(self):
widget = self.create()
self.checkPixelsParam(widget, 'selectborderwidth',
- 1.3, 2.6, -2, '10p', conv=False,
+ 1.3, 2.6, -2, '10p', conv=noconv,
keep_orig=tcl_version >= (8, 5))
def test_spacing1(self):
@@ -577,7 +578,11 @@ class TextTest(AbstractWidgetTest, unittest.TestCase):
def test_tabs(self):
widget = self.create()
- self.checkParam(widget, 'tabs', (10.2, 20.7, '1i', '2i'))
+ if get_tk_patchlevel() < (8, 5, 11):
+ self.checkParam(widget, 'tabs', (10.2, 20.7, '1i', '2i'),
+ expected=('10.2', '20.7', '1i', '2i'))
+ else:
+ self.checkParam(widget, 'tabs', (10.2, 20.7, '1i', '2i'))
self.checkParam(widget, 'tabs', '10.2 20.7 1i 2i',
expected=('10.2', '20.7', '1i', '2i'))
self.checkParam(widget, 'tabs', '2c left 4c 6c center',
diff --git a/Lib/lib-tk/test/test_ttk/support.py b/Lib/lib-tk/test/test_ttk/support.py
index 922c897..e10f80c 100644
--- a/Lib/lib-tk/test/test_ttk/support.py
+++ b/Lib/lib-tk/test/test_ttk/support.py
@@ -41,6 +41,21 @@ def requires_tcl(*version):
return unittest.skipUnless(tcl_version >= version,
'requires Tcl version >= ' + '.'.join(map(str, version)))
+_tk_patchlevel = None
+def get_tk_patchlevel():
+ global _tk_patchlevel
+ if _tk_patchlevel is None:
+ tcl = Tkinter.Tcl()
+ patchlevel = []
+ for x in tcl.call('info', 'patchlevel').split('.'):
+ try:
+ x = int(x, 10)
+ except ValueError:
+ x = -1
+ patchlevel.append(x)
+ _tk_patchlevel = tuple(patchlevel)
+ return _tk_patchlevel
+
units = {
'c': 72 / 2.54, # centimeters
'i': 72, # inches
diff --git a/Lib/lib-tk/test/widget_tests.py b/Lib/lib-tk/test/widget_tests.py
index f17ea5f..e02ff76 100644
--- a/Lib/lib-tk/test/widget_tests.py
+++ b/Lib/lib-tk/test/widget_tests.py
@@ -2,31 +2,23 @@
import Tkinter
from ttk import setup_master, Scale
-from test_ttk.support import tcl_version, requires_tcl, pixels_conv, tcl_obj_eq
+from test_ttk.support import (tcl_version, requires_tcl, get_tk_patchlevel,
+ pixels_conv, tcl_obj_eq)
-noconv = str if tcl_version < (8, 5) else False
+noconv = noconv_meth = False
+if get_tk_patchlevel() < (8, 5, 11):
+ noconv = str
noconv_meth = noconv and staticmethod(noconv)
def int_round(x):
return int(round(x))
pixels_round = int_round
-if tcl_version[:2] == (8, 5):
+if get_tk_patchlevel()[:3] == (8, 5, 11):
# Issue #19085: Workaround a bug in Tk
# http://core.tcl.tk/tk/info/3497848
- _pixels_round = None
- def pixels_round(x):
- global _pixels_round
- if _pixels_round is None:
- root = setup_master()
- patchlevel = root.call('info', 'patchlevel')
- patchlevel = tuple(map(int, patchlevel.split('.')))
- if patchlevel < (8, 5, 12):
- _pixels_round = int
- else:
- _pixels_round = int_round
- return _pixels_round(x)
+ pixels_round = int
_sentinel = object()
@@ -424,10 +416,7 @@ class StandardOptionsTests(object):
def test_wraplength(self):
widget = self.create()
- if tcl_version < (8, 5):
- self.checkPixelsParam(widget, 'wraplength', 100)
- else:
- self.checkParams(widget, 'wraplength', 100)
+ self.checkPixelsParam(widget, 'wraplength', 100)
def test_xscrollcommand(self):
widget = self.create()