summaryrefslogtreecommitdiffstats
path: root/Lib/tkinter/test/test_tkinter
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-03-17 11:05:52 (GMT)
committerGitHub <noreply@github.com>2022-03-17 11:05:52 (GMT)
commitc2e3c06139e9468efb32629d147d99a1672d9e19 (patch)
tree39d3a7a04231ee4c4f34bf1eab01afdd83a1b2e4 /Lib/tkinter/test/test_tkinter
parent7aeb06f78ee4abba64ca2c5c7a848fd2616da6fb (diff)
downloadcpython-c2e3c06139e9468efb32629d147d99a1672d9e19.zip
cpython-c2e3c06139e9468efb32629d147d99a1672d9e19.tar.gz
cpython-c2e3c06139e9468efb32629d147d99a1672d9e19.tar.bz2
bpo-46996: Remove support of Tcl/Tk < 8.5.12 (GH-31839)
Diffstat (limited to 'Lib/tkinter/test/test_tkinter')
-rw-r--r--Lib/tkinter/test/test_tkinter/test_geometry_managers.py37
-rw-r--r--Lib/tkinter/test/test_tkinter/test_widgets.py77
2 files changed, 39 insertions, 75 deletions
diff --git a/Lib/tkinter/test/test_tkinter/test_geometry_managers.py b/Lib/tkinter/test/test_tkinter/test_geometry_managers.py
index c645d43..c89bc8d 100644
--- a/Lib/tkinter/test/test_tkinter/test_geometry_managers.py
+++ b/Lib/tkinter/test/test_tkinter/test_geometry_managers.py
@@ -4,7 +4,7 @@ import tkinter
from tkinter import TclError
from test.support import requires
-from tkinter.test.support import pixels_conv, tcl_version, requires_tcl
+from tkinter.test.support import pixels_conv
from tkinter.test.widget_tests import AbstractWidgetTest
requires('gui')
@@ -295,8 +295,7 @@ class PlaceTest(AbstractWidgetTest, unittest.TestCase):
with self.assertRaisesRegex(TclError, "can't place %s relative to "
"itself" % re.escape(str(f2))):
f2.place_configure(in_=f2)
- if tcl_version >= (8, 5):
- self.assertEqual(f2.winfo_manager(), '')
+ self.assertEqual(f2.winfo_manager(), '')
with self.assertRaisesRegex(TclError, 'bad window path name'):
f2.place_configure(in_='spam')
f2.place_configure(in_=f)
@@ -491,8 +490,7 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
for i in range(rows + 1):
self.root.grid_rowconfigure(i, weight=0, minsize=0, pad=0, uniform='')
self.root.grid_propagate(1)
- if tcl_version >= (8, 5):
- self.root.grid_anchor('nw')
+ self.root.grid_anchor('nw')
super().tearDown()
def test_grid_configure(self):
@@ -619,16 +617,14 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
self.root.grid_columnconfigure((0, 3))
b = tkinter.Button(self.root)
b.grid_configure(column=0, row=0)
- if tcl_version >= (8, 5):
- self.root.grid_columnconfigure('all', weight=3)
- with self.assertRaisesRegex(TclError, 'expected integer but got "all"'):
- self.root.grid_columnconfigure('all')
- self.assertEqual(self.root.grid_columnconfigure(0, 'weight'), 3)
+ self.root.grid_columnconfigure('all', weight=3)
+ with self.assertRaisesRegex(TclError, 'expected integer but got "all"'):
+ self.root.grid_columnconfigure('all')
+ self.assertEqual(self.root.grid_columnconfigure(0, 'weight'), 3)
self.assertEqual(self.root.grid_columnconfigure(3, 'weight'), 2)
self.assertEqual(self.root.grid_columnconfigure(265, 'weight'), 0)
- if tcl_version >= (8, 5):
- self.root.grid_columnconfigure(b, weight=4)
- self.assertEqual(self.root.grid_columnconfigure(0, 'weight'), 4)
+ self.root.grid_columnconfigure(b, weight=4)
+ self.assertEqual(self.root.grid_columnconfigure(0, 'weight'), 4)
def test_grid_columnconfigure_minsize(self):
with self.assertRaisesRegex(TclError, 'bad screen distance "foo"'):
@@ -675,16 +671,14 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
self.root.grid_rowconfigure((0, 3))
b = tkinter.Button(self.root)
b.grid_configure(column=0, row=0)
- if tcl_version >= (8, 5):
- self.root.grid_rowconfigure('all', weight=3)
- with self.assertRaisesRegex(TclError, 'expected integer but got "all"'):
- self.root.grid_rowconfigure('all')
- self.assertEqual(self.root.grid_rowconfigure(0, 'weight'), 3)
+ self.root.grid_rowconfigure('all', weight=3)
+ with self.assertRaisesRegex(TclError, 'expected integer but got "all"'):
+ self.root.grid_rowconfigure('all')
+ self.assertEqual(self.root.grid_rowconfigure(0, 'weight'), 3)
self.assertEqual(self.root.grid_rowconfigure(3, 'weight'), 2)
self.assertEqual(self.root.grid_rowconfigure(265, 'weight'), 0)
- if tcl_version >= (8, 5):
- self.root.grid_rowconfigure(b, weight=4)
- self.assertEqual(self.root.grid_rowconfigure(0, 'weight'), 4)
+ self.root.grid_rowconfigure(b, weight=4)
+ self.assertEqual(self.root.grid_rowconfigure(0, 'weight'), 4)
def test_grid_rowconfigure_minsize(self):
with self.assertRaisesRegex(TclError, 'bad screen distance "foo"'):
@@ -774,7 +768,6 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
self.assertEqual(info['pady'], self._str(4))
self.assertEqual(info['sticky'], 'ns')
- @requires_tcl(8, 5)
def test_grid_anchor(self):
with self.assertRaisesRegex(TclError, 'bad anchor "x"'):
self.root.grid_anchor('x')
diff --git a/Lib/tkinter/test/test_tkinter/test_widgets.py b/Lib/tkinter/test/test_tkinter/test_widgets.py
index c0b92bf..fe8ecfe 100644
--- a/Lib/tkinter/test/test_tkinter/test_widgets.py
+++ b/Lib/tkinter/test/test_tkinter/test_widgets.py
@@ -4,11 +4,11 @@ from tkinter import TclError
import os
from test.support import requires
-from tkinter.test.support import (tcl_version, requires_tcl,
+from tkinter.test.support import (requires_tcl,
get_tk_patchlevel, widget_eq,
AbstractDefaultRootTest)
from tkinter.test.widget_tests import (
- add_standard_options, noconv, pixels_round,
+ add_standard_options,
AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests,
setUpModule)
@@ -20,7 +20,7 @@ def float_round(x):
class AbstractToplevelTest(AbstractWidgetTest, PixelSizeTests):
- _conv_pad_pixels = noconv
+ _conv_pad_pixels = False
def test_configure_class(self):
widget = self.create()
@@ -139,7 +139,7 @@ class LabelFrameTest(AbstractToplevelTest, unittest.TestCase):
class AbstractLabelTest(AbstractWidgetTest, IntegerSizeTests):
- _conv_pixels = noconv
+ _conv_pixels = False
def test_configure_highlightthickness(self):
widget = self.create()
@@ -249,7 +249,7 @@ class MenubuttonTest(AbstractLabelTest, unittest.TestCase):
'takefocus', 'text', 'textvariable',
'underline', 'width', 'wraplength',
)
- _conv_pixels = staticmethod(pixels_round)
+ _conv_pixels = round
def create(self, **kwargs):
return tkinter.Menubutton(self.root, **kwargs)
@@ -345,10 +345,7 @@ class EntryTest(AbstractWidgetTest, unittest.TestCase):
self.checkPixelsParam(widget, 'insertwidth', 1.3, 3.6, '10p')
self.checkParam(widget, 'insertwidth', 0.1, expected=2)
self.checkParam(widget, 'insertwidth', -2, expected=2)
- if pixels_round(0.9) <= 0:
- self.checkParam(widget, 'insertwidth', 0.9, expected=2)
- else:
- self.checkParam(widget, 'insertwidth', 0.9, expected=1)
+ self.checkParam(widget, 'insertwidth', 0.9, expected=1)
def test_configure_invalidcommand(self):
widget = self.create()
@@ -550,8 +547,6 @@ class TextTest(AbstractWidgetTest, unittest.TestCase):
'tabs', 'tabstyle', 'takefocus', 'undo', 'width', 'wrap',
'xscrollcommand', 'yscrollcommand',
)
- if tcl_version < (8, 5):
- _stringify = True
def create(self, **kwargs):
return tkinter.Text(self.root, **kwargs)
@@ -560,12 +555,10 @@ class TextTest(AbstractWidgetTest, unittest.TestCase):
widget = self.create()
self.checkBooleanParam(widget, 'autoseparators')
- @requires_tcl(8, 5)
def test_configure_blockcursor(self):
widget = self.create()
self.checkBooleanParam(widget, 'blockcursor')
- @requires_tcl(8, 5)
def test_configure_endline(self):
widget = self.create()
text = '\n'.join('Line %d' for i in range(100))
@@ -589,7 +582,6 @@ class TextTest(AbstractWidgetTest, unittest.TestCase):
widget = self.create()
self.checkIntegerParam(widget, 'maxundo', 0, 5, -1)
- @requires_tcl(8, 5)
def test_configure_inactiveselectbackground(self):
widget = self.create()
self.checkColorParam(widget, 'inactiveselectbackground')
@@ -603,8 +595,7 @@ class TextTest(AbstractWidgetTest, unittest.TestCase):
def test_configure_selectborderwidth(self):
widget = self.create()
self.checkPixelsParam(widget, 'selectborderwidth',
- 1.3, 2.6, -2, '10p', conv=noconv,
- keep_orig=tcl_version >= (8, 5))
+ 1.3, 2.6, -2, '10p', conv=False)
def test_configure_spacing1(self):
widget = self.create()
@@ -621,7 +612,6 @@ class TextTest(AbstractWidgetTest, unittest.TestCase):
self.checkPixelsParam(widget, 'spacing3', 20, 21.4, 22.6, '0.5c')
self.checkParam(widget, 'spacing3', -10, expected=0)
- @requires_tcl(8, 5)
def test_configure_startline(self):
widget = self.create()
text = '\n'.join('Line %d' for i in range(100))
@@ -637,27 +627,18 @@ class TextTest(AbstractWidgetTest, unittest.TestCase):
def test_configure_state(self):
widget = self.create()
- if tcl_version < (8, 5):
- self.checkParams(widget, 'state', 'disabled', 'normal')
- else:
- self.checkEnumParam(widget, 'state', 'disabled', 'normal')
+ self.checkEnumParam(widget, 'state', 'disabled', 'normal')
def test_configure_tabs(self):
widget = self.create()
- 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'))
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',
expected=('2c', 'left', '4c', '6c', 'center'))
self.checkInvalidParam(widget, 'tabs', 'spam',
- errmsg='bad screen distance "spam"',
- keep_orig=tcl_version >= (8, 5))
+ errmsg='bad screen distance "spam"')
- @requires_tcl(8, 5)
def test_configure_tabstyle(self):
widget = self.create()
self.checkEnumParam(widget, 'tabstyle', 'tabular', 'wordprocessor')
@@ -674,10 +655,7 @@ class TextTest(AbstractWidgetTest, unittest.TestCase):
def test_configure_wrap(self):
widget = self.create()
- if tcl_version < (8, 5):
- self.checkParams(widget, 'wrap', 'char', 'none', 'word')
- else:
- self.checkEnumParam(widget, 'wrap', 'char', 'none', 'word')
+ self.checkEnumParam(widget, 'wrap', 'char', 'none', 'word')
def test_bbox(self):
widget = self.create()
@@ -1055,12 +1033,12 @@ class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
def test_configure_handlesize(self):
widget = self.create()
self.checkPixelsParam(widget, 'handlesize', 8, 9.4, 10.6, -3, '2m',
- conv=noconv)
+ conv=False)
def test_configure_height(self):
widget = self.create()
self.checkPixelsParam(widget, 'height', 100, 101.2, 102.6, -100, 0, '1i',
- conv=noconv)
+ conv=False)
def test_configure_opaqueresize(self):
widget = self.create()
@@ -1076,7 +1054,7 @@ class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
widget = self.create()
self.checkPixelsParam(widget, 'proxyborderwidth',
0, 1.3, 2.9, 6, -2, '10p',
- conv=noconv)
+ conv=False)
@requires_tcl(8, 6, 5)
def test_configure_proxyrelief(self):
@@ -1098,7 +1076,7 @@ class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
def test_configure_sashwidth(self):
widget = self.create()
self.checkPixelsParam(widget, 'sashwidth', 10, 11.1, 15.6, -3, '1m',
- conv=noconv)
+ conv=False)
def test_configure_showhandle(self):
widget = self.create()
@@ -1107,7 +1085,7 @@ class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
def test_configure_width(self):
widget = self.create()
self.checkPixelsParam(widget, 'width', 402, 403.4, 404.6, -402, 0, '5i',
- conv=noconv)
+ conv=False)
def create2(self):
p = self.create()
@@ -1127,15 +1105,12 @@ class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
self.assertEqual(v, p.paneconfigure(b, k))
self.assertEqual(v[4], p.panecget(b, k))
- def check_paneconfigure(self, p, b, name, value, expected, stringify=False):
- conv = lambda x: x
- if not self.wantobjects or stringify:
+ def check_paneconfigure(self, p, b, name, value, expected):
+ if not self.wantobjects:
expected = str(expected)
- if self.wantobjects and stringify:
- conv = str
p.paneconfigure(b, **{name: value})
- self.assertEqual(conv(p.paneconfigure(b, name)[4]), expected)
- self.assertEqual(conv(p.panecget(b, name)), expected)
+ self.assertEqual(p.paneconfigure(b, name)[4], expected)
+ self.assertEqual(p.panecget(b, name), expected)
def check_paneconfigure_bad(self, p, b, name, msg):
with self.assertRaisesRegex(TclError, msg):
@@ -1155,12 +1130,10 @@ class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
def test_paneconfigure_height(self):
p, b, c = self.create2()
- self.check_paneconfigure(p, b, 'height', 10, 10,
- stringify=get_tk_patchlevel() < (8, 5, 11))
+ self.check_paneconfigure(p, b, 'height', 10, 10)
self.check_paneconfigure_bad(p, b, 'height',
'bad screen distance "badValue"')
- @requires_tcl(8, 5)
def test_paneconfigure_hide(self):
p, b, c = self.create2()
self.check_paneconfigure(p, b, 'hide', False, 0)
@@ -1193,7 +1166,6 @@ class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
'be a string containing zero or more of '
'n, e, s, and w')
- @requires_tcl(8, 5)
def test_paneconfigure_stretch(self):
p, b, c = self.create2()
self.check_paneconfigure(p, b, 'stretch', 'alw', 'always')
@@ -1203,8 +1175,7 @@ class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
def test_paneconfigure_width(self):
p, b, c = self.create2()
- self.check_paneconfigure(p, b, 'width', 10, 10,
- stringify=get_tk_patchlevel() < (8, 5, 11))
+ self.check_paneconfigure(p, b, 'width', 10, 10)
self.check_paneconfigure_bad(p, b, 'width',
'bad screen distance "badValue"')
@@ -1218,7 +1189,7 @@ class MenuTest(AbstractWidgetTest, unittest.TestCase):
'postcommand', 'relief', 'selectcolor', 'takefocus',
'tearoff', 'tearoffcommand', 'title', 'type',
)
- _conv_pixels = noconv
+ _conv_pixels = False
def create(self, **kwargs):
return tkinter.Menu(self.root, **kwargs)
@@ -1290,7 +1261,7 @@ class MessageTest(AbstractWidgetTest, unittest.TestCase):
'justify', 'padx', 'pady', 'relief',
'takefocus', 'text', 'textvariable', 'width',
)
- _conv_pad_pixels = noconv
+ _conv_pad_pixels = False
def create(self, **kwargs):
return tkinter.Message(self.root, **kwargs)