Skip to content

Commit 0d2337a

Browse files
committed
Changes to tkinter for Tk 8.6.15 and 9.0
1 parent 112b170 commit 0d2337a

File tree

5 files changed

+239
-147
lines changed

5 files changed

+239
-147
lines changed

Lib/test/test_tkinter/support.py

+17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
import functools
2+
import re
23
import tkinter
34

5+
messages_v1 = {
6+
'no_busy': 'can\'t find busy window.*',
7+
'no_font': 'font "{}" doesn\'t exist',
8+
'no_image': 'image "{}" doesn\'t exist',
9+
}
10+
11+
messages_v2 = {
12+
'no_busy': 'cannot find busy window',
13+
'no_font': 'font "{}" does not exist',
14+
'no_image': 'image "{}" does not exist',
15+
}
16+
417
class AbstractTkTest:
518

619
@classmethod
@@ -112,6 +125,10 @@ def get_tk_patchlevel(root):
112125
def pixels_conv(value):
113126
return float(value[:-1]) * units[value[-1:]]
114127

128+
pix_re = re.compile(r'[0-9]*\.?[0-9]*[cimp]{1}')
129+
def is_pixel_str(x):
130+
return pix_re.fullmatch(x) != None
131+
115132
def tcl_obj_eq(actual, expected):
116133
if actual == expected:
117134
return True

Lib/test/test_tkinter/test_misc.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44
from tkinter import TclError
55
import enum
66
from test import support
7-
from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest, requires_tk
7+
from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest, requires_tk, tk_version
88

99
support.requires('gui')
1010

11+
if tk_version < (9,0):
12+
from test.test_tkinter.support import messages_v1 as messages
13+
else:
14+
from test.test_tkinter.support import messages_v2 as messages
15+
1116
class MiscTest(AbstractTkTest, unittest.TestCase):
1217

1318
def test_all(self):
@@ -66,9 +71,9 @@ def test_tk_busy(self):
6671
f.tk_busy_forget()
6772
self.assertFalse(f.tk_busy_status())
6873
self.assertFalse(f.tk_busy_current())
69-
with self.assertRaisesRegex(TclError, "can't find busy window"):
74+
with self.assertRaisesRegex(TclError, messages['no_busy']):
7075
f.tk_busy_configure()
71-
with self.assertRaisesRegex(TclError, "can't find busy window"):
76+
with self.assertRaisesRegex(TclError, messages['no_busy']):
7277
f.tk_busy_forget()
7378

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

8994
f.tk_busy_forget()
90-
with self.assertRaisesRegex(TclError, "can't find busy window"):
95+
print('>>>>>2', messages['no_busy'])
96+
with self.assertRaisesRegex(TclError, messaages["no_busy"]):
9197
f.tk_busy_cget('cursor')
9298

9399
def test_tk_setPalette(self):

0 commit comments

Comments
 (0)