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-124111: Update tkinter and test_tkinter to use either Tcl/Tk 8.6.15 or Tcl/Tk 9.0. #124112

Closed
wants to merge 3 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
17 changes: 17 additions & 0 deletions Lib/test/test_tkinter/support.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import functools
import re
import tkinter

messages_v1 = {
'no_busy': 'can\'t find busy window.*',
'no_font': 'font "{}" doesn\'t exist',
'no_image': 'image "{}" doesn\'t exist',
}

messages_v2 = {
'no_busy': 'cannot find busy window',
'no_font': 'font "{}" does not exist',
'no_image': 'image "{}" does not exist',
}

class AbstractTkTest:

@classmethod
Expand Down Expand Up @@ -112,6 +125,10 @@ def get_tk_patchlevel(root):
def pixels_conv(value):
return float(value[:-1]) * units[value[-1:]]

pix_re = re.compile(r'[0-9]*\.?[0-9]*[cimp]{1}')
def is_pixel_str(x):
return pix_re.fullmatch(x) != None

def tcl_obj_eq(actual, expected):
if actual == expected:
return True
Expand Down
13 changes: 9 additions & 4 deletions Lib/test/test_tkinter/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
from tkinter import TclError
import enum
from test import support
from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest, requires_tk
from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest, requires_tk, tk_version

support.requires('gui')

if tk_version < (9,0):
from test.test_tkinter.support import messages_v1 as messages
else:
from test.test_tkinter.support import messages_v2 as messages

class MiscTest(AbstractTkTest, unittest.TestCase):

def test_all(self):
Expand Down Expand Up @@ -66,9 +71,9 @@ def test_tk_busy(self):
f.tk_busy_forget()
self.assertFalse(f.tk_busy_status())
self.assertFalse(f.tk_busy_current())
with self.assertRaisesRegex(TclError, "can't find busy window"):
with self.assertRaisesRegex(TclError, messages['no_busy']):
f.tk_busy_configure()
with self.assertRaisesRegex(TclError, "can't find busy window"):
with self.assertRaisesRegex(TclError, messages['no_busy']):
f.tk_busy_forget()

@requires_tk(8, 6, 6)
Expand All @@ -87,7 +92,7 @@ def test_tk_busy_with_cursor(self):
self.assertEqual(f.tk_busy_configure('cursor')[4], 'heart')

f.tk_busy_forget()
with self.assertRaisesRegex(TclError, "can't find busy window"):
with self.assertRaisesRegex(TclError, messages["no_busy"]):
f.tk_busy_cget('cursor')

def test_tk_setPalette(self):
Expand Down
Loading
Loading