Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 92af06b

Browse files
Issue #19320: Fixed split/splitlist tests in test_tcl for Tcl 8.5.0-8.5.5.
1 parent 091d386 commit 92af06b

1 file changed

Lines changed: 28 additions & 5 deletions

File tree

Lib/test/test_tcl.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@
2121
pass
2222
tcl_version = tuple(tcl_version)
2323

24+
_tk_patchlevel = None
25+
def get_tk_patchlevel():
26+
global _tk_patchlevel
27+
if _tk_patchlevel is None:
28+
tcl = Tcl()
29+
patchlevel = []
30+
for x in tcl.call('info', 'patchlevel').split('.'):
31+
try:
32+
x = int(x, 10)
33+
except ValueError:
34+
x = -1
35+
patchlevel.append(x)
36+
_tk_patchlevel = tuple(patchlevel)
37+
return _tk_patchlevel
38+
2439

2540
class TkinterTest(unittest.TestCase):
2641

@@ -259,10 +274,14 @@ def test_splitlist(self):
259274
('1', '2', '3.4')),
260275
]
261276
if tcl_version >= (8, 5):
277+
if not self.wantobjects or get_tk_patchlevel() < (8, 5, 5):
278+
# Before 8.5.5 dicts were converted to lists through string
279+
expected = ('12', '\u20ac', '\u20ac', '3.4')
280+
else:
281+
expected = (12, '\u20ac', '\u20ac', (3.4,))
262282
testcases += [
263-
(call('dict', 'create', 1, '\u20ac', b'\xe2\x82\xac', (3.4,)),
264-
(1, '\u20ac', '\u20ac', (3.4,)) if self.wantobjects else
265-
('1', '\u20ac', '\u20ac', '3.4')),
283+
(call('dict', 'create', 12, '\u20ac', b'\xe2\x82\xac', (3.4,)),
284+
expected),
266285
]
267286
for arg, res in testcases:
268287
self.assertEqual(splitlist(arg), res, msg=arg)
@@ -299,10 +318,14 @@ def test_split(self):
299318
('1', '2', '3.4')),
300319
]
301320
if tcl_version >= (8, 5):
321+
if not self.wantobjects or get_tk_patchlevel() < (8, 5, 5):
322+
# Before 8.5.5 dicts were converted to lists through string
323+
expected = ('12', '\u20ac', '\u20ac', '3.4')
324+
else:
325+
expected = (12, '\u20ac', '\u20ac', (3.4,))
302326
testcases += [
303327
(call('dict', 'create', 12, '\u20ac', b'\xe2\x82\xac', (3.4,)),
304-
(12, '\u20ac', '\u20ac', (3.4,)) if self.wantobjects else
305-
('12', '\u20ac', '\u20ac', '3.4')),
328+
expected),
306329
]
307330
for arg, res in testcases:
308331
self.assertEqual(split(arg), res, msg=arg)

0 commit comments

Comments
 (0)