Skip to content

gh-104855: Update Tkinter tests for Tcl/Tk 8.7 and 9.0 #120824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
deef967
gh-104855: Update more tk tests for 8.7
terryjreedy May 29, 2023
358bb74
whitespace
terryjreedy May 29, 2023
ca70095
Merge branch 'main' into tk87tests
serhiy-storchaka May 31, 2024
11629b8
Fix errmsg for the last empty value.
serhiy-storchaka May 31, 2024
907abd0
Simplify the errmsg for place_configure().
serhiy-storchaka May 31, 2024
d9d7dc8
Merge branch 'main' into tk87tests
serhiy-storchaka May 31, 2024
a1279f3
Fix fixes for options -underline, -to and -from.
serhiy-storchaka May 31, 2024
f90b94d
Fix test_create_polygon.
serhiy-storchaka May 31, 2024
6ccd8fe
Fix more tests.
serhiy-storchaka May 31, 2024
fae9d85
Fix test_configure_from and test_configure_to.
serhiy-storchaka Jun 1, 2024
f6b26cf
Polishing.
serhiy-storchaka Jun 1, 2024
9441f07
Fix more tests.
serhiy-storchaka Jun 1, 2024
63d9480
Fix for wantobjects=0.
serhiy-storchaka Jun 1, 2024
dfebcde
Update the NEWS entry.
serhiy-storchaka Jun 1, 2024
d48dca6
Merge branch 'main' into tk87tests
serhiy-storchaka Jun 1, 2024
d30d55c
Fix tests with Tcl/Tk 8.6.
serhiy-storchaka Jun 1, 2024
d18b841
Fix tests for newer Tk 8.7.
serhiy-storchaka Jun 4, 2024
93ffd33
Fix tests on Tcl/Tk 9.0.
serhiy-storchaka Jun 4, 2024
8f18aca
Fix tests on Tcl/Tk 8.7.
serhiy-storchaka Jun 4, 2024
f6ce718
Simplify test code.
serhiy-storchaka Jun 4, 2024
66f0cd5
Merge branch 'main' into tk87tests
serhiy-storchaka Jun 4, 2024
55a96fc
Update NEWS.
serhiy-storchaka Jun 4, 2024
10baa24
Remove the NEWS entry.
serhiy-storchaka Jun 4, 2024
f784360
Polishing.
serhiy-storchaka Jun 5, 2024
b72910f
Refactor test_configure_underline.
serhiy-storchaka Jun 5, 2024
bfd47d1
Remove special test_configure_padx for the message widget.
serhiy-storchaka Jun 6, 2024
289c4ae
Refactor test_configure_highlightthickness.
serhiy-storchaka Jun 6, 2024
19232e7
Polishing.
serhiy-storchaka Jun 6, 2024
dea00ba
Merge branch 'main' into tk87tests
serhiy-storchaka Jun 6, 2024
1224d11
Merge branch 'main' into tk87tests
serhiy-storchaka Jun 7, 2024
59e0b40
Fix some typos.
serhiy-storchaka Jun 7, 2024
be01369
Update Tcl/Tk.
serhiy-storchaka Jun 21, 2024
2aa56da
Merge branch 'main' into tk90tests
serhiy-storchaka Jun 21, 2024
0c7d851
Refactor.
serhiy-storchaka Jun 21, 2024
c9ab1a5
Polishing.
serhiy-storchaka Jun 21, 2024
c25d025
Polishing.
serhiy-storchaka Jun 21, 2024
7dc7b5a
Match full errmsg.
serhiy-storchaka Jun 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Lib/test/test_tcl.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,18 @@ def test_evalfile_surrogates_in_result(self):
with open(filename, 'wb') as f:
f.write(b"""
set a "<\xed\xa0\xbd\xed\xb2\xbb>"
""")
if tcl_version >= (9, 0):
self.assertRaises(TclError, tcl.evalfile, filename)
else:
tcl.evalfile(filename)
self.assertEqual(tcl.eval('set a'), '<\U0001f4bb>')

with open(filename, 'wb') as f:
f.write(b"""
set b "<\\ud83d\\udcbb>"
""")
tcl.evalfile(filename)
self.assertEqual(tcl.eval('set a'), '<\U0001f4bb>')
self.assertEqual(tcl.eval('set b'), '<\U0001f4bb>')

def testEvalFileException(self):
Expand Down
47 changes: 29 additions & 18 deletions Lib/test/test_tkinter/test_geometry_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
requires('gui')


EXPECTED_FLOAT_ERRMSG = 'expected floating-point number but got "{}"'
EXPECTED_FLOAT_OR_EMPTY_ERRMSG = 'expected floating-point number (or "" )?but got "{}"'
EXPECTED_SCREEN_DISTANCE_ERRMSG = '(bad|expected) screen distance (but got )?"{}"'
EXPECTED_SCREEN_DISTANCE_OR_EMPTY_ERRMSG = '(bad|expected) screen distance (or "" but got )?"{}"'

class PackTest(AbstractWidgetTest, unittest.TestCase):

test_keys = None
Expand Down Expand Up @@ -317,7 +322,8 @@ def test_place_configure_x(self):
self.assertEqual(f2.place_info()['x'], '-10')
self.root.update()
self.assertEqual(f2.winfo_x(), 190)
with self.assertRaisesRegex(TclError, 'bad screen distance "spam"'):
with self.assertRaisesRegex(TclError,
EXPECTED_SCREEN_DISTANCE_ERRMSG.format('spam')):
f2.place_configure(in_=f, x='spam')

def test_place_configure_y(self):
Expand All @@ -334,7 +340,8 @@ def test_place_configure_y(self):
self.assertEqual(f2.place_info()['y'], '-10')
self.root.update()
self.assertEqual(f2.winfo_y(), 110)
with self.assertRaisesRegex(TclError, 'bad screen distance "spam"'):
with self.assertRaisesRegex(TclError,
EXPECTED_SCREEN_DISTANCE_ERRMSG.format('spam')):
f2.place_configure(in_=f, y='spam')

def test_place_configure_relx(self):
Expand All @@ -351,8 +358,7 @@ def test_place_configure_relx(self):
self.assertEqual(f2.place_info()['relx'], '1')
self.root.update()
self.assertEqual(f2.winfo_x(), 200)
with self.assertRaisesRegex(TclError, 'expected floating-point number '
'but got "spam"'):
with self.assertRaisesRegex(TclError, EXPECTED_FLOAT_ERRMSG.format('spam')):
f2.place_configure(in_=f, relx='spam')

def test_place_configure_rely(self):
Expand All @@ -369,8 +375,7 @@ def test_place_configure_rely(self):
self.assertEqual(f2.place_info()['rely'], '1')
self.root.update()
self.assertEqual(f2.winfo_y(), 120)
with self.assertRaisesRegex(TclError, 'expected floating-point number '
'but got "spam"'):
with self.assertRaisesRegex(TclError, EXPECTED_FLOAT_ERRMSG.format('spam')):
f2.place_configure(in_=f, rely='spam')

def test_place_configure_anchor(self):
Expand All @@ -391,7 +396,8 @@ def test_place_configure_width(self):
f2.place_configure(width='')
self.root.update()
self.assertEqual(f2.winfo_width(), 30)
with self.assertRaisesRegex(TclError, 'bad screen distance "abcd"'):
with self.assertRaisesRegex(TclError,
EXPECTED_SCREEN_DISTANCE_OR_EMPTY_ERRMSG.format('abcd')):
f2.place_configure(width='abcd')

def test_place_configure_height(self):
Expand All @@ -402,7 +408,8 @@ def test_place_configure_height(self):
f2.place_configure(height='')
self.root.update()
self.assertEqual(f2.winfo_height(), 60)
with self.assertRaisesRegex(TclError, 'bad screen distance "abcd"'):
with self.assertRaisesRegex(TclError,
EXPECTED_SCREEN_DISTANCE_OR_EMPTY_ERRMSG.format('abcd')):
f2.place_configure(height='abcd')

def test_place_configure_relwidth(self):
Expand All @@ -413,8 +420,7 @@ def test_place_configure_relwidth(self):
f2.place_configure(relwidth='')
self.root.update()
self.assertEqual(f2.winfo_width(), 30)
with self.assertRaisesRegex(TclError, 'expected floating-point number '
'but got "abcd"'):
with self.assertRaisesRegex(TclError, EXPECTED_FLOAT_OR_EMPTY_ERRMSG.format('abcd')):
f2.place_configure(relwidth='abcd')

def test_place_configure_relheight(self):
Expand All @@ -425,8 +431,7 @@ def test_place_configure_relheight(self):
f2.place_configure(relheight='')
self.root.update()
self.assertEqual(f2.winfo_height(), 60)
with self.assertRaisesRegex(TclError, 'expected floating-point number '
'but got "abcd"'):
with self.assertRaisesRegex(TclError, EXPECTED_FLOAT_OR_EMPTY_ERRMSG.format('abcd')):
f2.place_configure(relheight='abcd')

def test_place_configure_bordermode(self):
Expand Down Expand Up @@ -629,7 +634,8 @@ def test_grid_columnconfigure(self):
self.assertEqual(self.root.grid_columnconfigure(0, 'weight'), 4)

def test_grid_columnconfigure_minsize(self):
with self.assertRaisesRegex(TclError, 'bad screen distance "foo"'):
with self.assertRaisesRegex(TclError,
EXPECTED_SCREEN_DISTANCE_ERRMSG.format('foo')):
self.root.grid_columnconfigure(0, minsize='foo')
self.root.grid_columnconfigure(0, minsize=10)
self.assertEqual(self.root.grid_columnconfigure(0, 'minsize'), 10)
Expand All @@ -646,7 +652,8 @@ def test_grid_columnconfigure_weight(self):
self.assertEqual(self.root.grid_columnconfigure(0)['weight'], 3)

def test_grid_columnconfigure_pad(self):
with self.assertRaisesRegex(TclError, 'bad screen distance "foo"'):
with self.assertRaisesRegex(TclError,
EXPECTED_SCREEN_DISTANCE_ERRMSG.format('foo')):
self.root.grid_columnconfigure(0, pad='foo')
with self.assertRaisesRegex(TclError, 'invalid arg "-pad": '
'should be non-negative'):
Expand Down Expand Up @@ -683,7 +690,8 @@ def test_grid_rowconfigure(self):
self.assertEqual(self.root.grid_rowconfigure(0, 'weight'), 4)

def test_grid_rowconfigure_minsize(self):
with self.assertRaisesRegex(TclError, 'bad screen distance "foo"'):
with self.assertRaisesRegex(TclError,
EXPECTED_SCREEN_DISTANCE_ERRMSG.format('foo')):
self.root.grid_rowconfigure(0, minsize='foo')
self.root.grid_rowconfigure(0, minsize=10)
self.assertEqual(self.root.grid_rowconfigure(0, 'minsize'), 10)
Expand All @@ -700,7 +708,8 @@ def test_grid_rowconfigure_weight(self):
self.assertEqual(self.root.grid_rowconfigure(0)['weight'], 3)

def test_grid_rowconfigure_pad(self):
with self.assertRaisesRegex(TclError, 'bad screen distance "foo"'):
with self.assertRaisesRegex(TclError,
EXPECTED_SCREEN_DISTANCE_ERRMSG.format('foo')):
self.root.grid_rowconfigure(0, pad='foo')
with self.assertRaisesRegex(TclError, 'invalid arg "-pad": '
'should be non-negative'):
Expand Down Expand Up @@ -818,9 +827,11 @@ def test_grid_location(self):
self.root.grid_location(0)
with self.assertRaises(TypeError):
self.root.grid_location(0, 0, 0)
with self.assertRaisesRegex(TclError, 'bad screen distance "x"'):
with self.assertRaisesRegex(TclError,
EXPECTED_SCREEN_DISTANCE_ERRMSG.format('x')):
self.root.grid_location('x', 'y')
with self.assertRaisesRegex(TclError, 'bad screen distance "y"'):
with self.assertRaisesRegex(TclError,
EXPECTED_SCREEN_DISTANCE_ERRMSG.format('y')):
self.root.grid_location('1c', 'y')
t = self.root
# de-maximize
Expand Down
4 changes: 3 additions & 1 deletion Lib/test/test_tkinter/test_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from tkinter import (Variable, StringVar, IntVar, DoubleVar, BooleanVar, Tcl,
TclError)
from test.support import ALWAYS_EQ
from test.test_tkinter.support import AbstractDefaultRootTest
from test.test_tkinter.support import AbstractDefaultRootTest, tcl_version


class Var(Variable):
Expand Down Expand Up @@ -112,6 +112,8 @@ def test_initialize(self):
self.assertTrue(v.side_effect)

def test_trace_old(self):
if tcl_version >= (9, 0):
self.skipTest('requires Tcl version < 9.0')
# Old interface
v = Variable(self.root)
vname = str(v)
Expand Down
Loading
Loading