Skip to content
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

gh-104855: Update more tk tests for 8.7 #105047

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 7 additions & 4 deletions Lib/test/test_tkinter/test_geometry_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,11 @@ def test_place_configure_height(self):
with self.assertRaisesRegex(TclError, 'bad screen distance "abcd"'):
f2.place_configure(height='abcd')

def place_err(self, root):
tk86 = root.info_patchlevel() < (8, 7)
return ('expected floating-point number '
f'''{'' if tk86 else 'or "" '}but got "abcd"''')

def test_place_configure_relwidth(self):
t, f, f2 = self.create2()
f2.place_configure(in_=f, relwidth=0.5)
Expand All @@ -413,8 +418,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, self.place_err(self.root)):
f2.place_configure(relwidth='abcd')

def test_place_configure_relheight(self):
Expand All @@ -425,8 +429,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, self.place_err(self.root)):
f2.place_configure(relheight='abcd')

def test_place_configure_bordermode(self):
Expand Down
16 changes: 12 additions & 4 deletions Lib/test/test_tkinter/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,12 @@ def test_configure_from(self):
widget = self.create()
self.checkParam(widget, 'to', 100.0)
self.checkFloatParam(widget, 'from', -10, 10.2, 11.7)
self.checkInvalidParam(widget, 'from', 200,
errmsg='-to value must be greater than -from value')
if widget.info_patchlevel() < (8, 7):
self.checkInvalidParam(
widget, 'from', 200,
errmsg='-to value must be greater than -from value')
else:
self.checkFloatParam(widget, 'from', 200)

def test_configure_increment(self):
widget = self.create()
Expand All @@ -500,8 +504,12 @@ def test_configure_to(self):
widget = self.create()
self.checkParam(widget, 'from', -100.0)
self.checkFloatParam(widget, 'to', -10, 10.2, 11.7)
self.checkInvalidParam(widget, 'to', -200,
errmsg='-to value must be greater than -from value')
if widget.info_patchlevel() < (8, 7):
self.checkInvalidParam(
widget, 'to', -200,
errmsg='-to value must be greater than -from value')
else:
self.checkFloatParam(widget, 'to', -200)

def test_configure_values(self):
# XXX
Expand Down
18 changes: 12 additions & 6 deletions Lib/test/test_tkinter/widget_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ def checkParams(self, widget, name, *values, **kwargs):

def checkIntegerParam(self, widget, name, *values, **kwargs):
self.checkParams(widget, name, *values, **kwargs)
self.checkInvalidParam(widget, name, '',
errmsg='expected integer but got ""')
if tcl_version < (8, 7) or name == 'underline':
self.checkInvalidParam(widget, name, '',
errmsg='expected integer but got ""')
else:
self.checkParams(widget, 'underline', '')
self.checkInvalidParam(widget, name, '10p',
errmsg='expected integer but got "10p"')
self.checkInvalidParam(widget, name, 3.2,
Expand Down Expand Up @@ -152,10 +155,13 @@ def checkPixelsParam(self, widget, name, *values,
errmsg='bad screen distance "spam"')

def checkReliefParam(self, widget, name):
self.checkParams(widget, name,
'flat', 'groove', 'raised', 'ridge', 'solid', 'sunken')
errmsg='bad relief "spam": must be '\
'flat, groove, raised, ridge, solid, or sunken'
options = ['flat', 'groove', 'raised', 'ridge', 'solid', 'sunken']
if tcl_version >= (8, 7) and name in ('overrelief', 'proxyrelief'):
options.append('')
self.checkParams(widget, name, *options)
lastop = options.pop()
opstring = ', '.join(options)
errmsg=f'bad relief "spam": must be {opstring}, or {lastop}'
if tcl_version < (8, 6):
errmsg = None
self.checkInvalidParam(widget, name, 'spam',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Where applicable update tkinter tests for 8.7 by adding '' to options in
error messages, testing '' for validity, and testing acceptance of 'to'
value < 'from' value in a spinbox (which switches the values).