diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-11-04 21:06:51 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-11-04 21:06:51 (GMT) |
commit | b58d4a32090185e605db4db461732393b4596b0f (patch) | |
tree | fec1289cdcd154702853c1a4f38efde3dc294343 /Lib/tkinter | |
parent | 20acaa7a0a397262711bcc6333ca01f4848536bf (diff) | |
parent | 2028e0131396258d7aa5052304863e7ca5af6ab9 (diff) | |
download | cpython-b58d4a32090185e605db4db461732393b4596b0f.zip cpython-b58d4a32090185e605db4db461732393b4596b0f.tar.gz cpython-b58d4a32090185e605db4db461732393b4596b0f.tar.bz2 |
Issue #19085: Fix running test_ttk_textonly on displayless host.
Diffstat (limited to 'Lib/tkinter')
-rw-r--r-- | Lib/tkinter/test/test_tkinter/test_widgets.py | 5 | ||||
-rw-r--r-- | Lib/tkinter/test/widget_tests.py | 20 |
2 files changed, 16 insertions, 9 deletions
diff --git a/Lib/tkinter/test/test_tkinter/test_widgets.py b/Lib/tkinter/test/test_tkinter/test_widgets.py index e38fb3f..78ba14f 100644 --- a/Lib/tkinter/test/test_tkinter/test_widgets.py +++ b/Lib/tkinter/test/test_tkinter/test_widgets.py @@ -4,7 +4,8 @@ import os from test.support import requires from tkinter.test.support import tcl_version, requires_tcl, widget_eq -from tkinter.test.widget_tests import (add_standard_options, noconv, +from tkinter.test.widget_tests import ( + add_standard_options, noconv, pixels_round, AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests) requires('gui') @@ -243,7 +244,7 @@ class MenubuttonTest(AbstractLabelTest, unittest.TestCase): 'takefocus', 'text', 'textvariable', 'underline', 'width', 'wraplength', ) - _conv_pixels = AbstractWidgetTest._conv_pixels + _conv_pixels = staticmethod(pixels_round) def _create(self, **kwargs): return tkinter.Menubutton(self.root, **kwargs) diff --git a/Lib/tkinter/test/widget_tests.py b/Lib/tkinter/test/widget_tests.py index 28cc986..e488565 100644 --- a/Lib/tkinter/test/widget_tests.py +++ b/Lib/tkinter/test/widget_tests.py @@ -12,18 +12,24 @@ pixels_round = round if tcl_version[:2] == (8, 5): # Issue #19085: Workaround a bug in Tk # http://core.tcl.tk/tk/info/3497848 - root = setup_master() - patchlevel = root.call('info', 'patchlevel') - patchlevel = tuple(map(int, patchlevel.split('.'))) - if patchlevel < (8, 5, 12): - pixels_round = int - del root + _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) _sentinel = object() class AbstractWidgetTest: - _conv_pixels = pixels_round + _conv_pixels = staticmethod(pixels_round) _conv_pad_pixels = None wantobjects = True |