Skip to content

Commit 78f8a9b

Browse files
committed
add check_tk_version() to support, to avoid tests on too new a version of Tk
1 parent 599be68 commit 78f8a9b

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

Lib/test/support/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2992,3 +2992,16 @@ def is_libssl_fips_mode():
29922992
except ImportError:
29932993
return False # more of a maybe, unless we add this to the _ssl module.
29942994
return get_fips_mode() != 0
2995+
2996+
2997+
def check_tk_version():
2998+
from .import_helper import import_module
2999+
import_module('_tkinter')
3000+
import tkinter
3001+
tcl = tkinter.Tcl()
3002+
major, minor, micro = tcl.call("info", "patchlevel").split(".")
3003+
version = f"{int(major):02d}{int(minor):02d}{int(micro):02d}"
3004+
# update max version number as necessary
3005+
if version > "080699":
3006+
raise unittest.SkipTest(f"Tk version {major}.{minor}.{micro}"
3007+
" not supported")

Lib/test/test_tkinter/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import_helper,
77
load_package_tests,
88
requires,
9+
check_tk_version,
910
)
1011

1112

@@ -19,6 +20,16 @@
1920
# Skip test if tk cannot be initialized.
2021
requires('gui')
2122

23+
# Skip test if tk version is too new.
24+
check_tk_version()
25+
26+
27+
import tkinter
28+
tcl = tkinter.Tcl()
29+
major, minor, micro = tcl.call("info", "patchlevel").split(".")
30+
version = f"{int(major):02d}{int(minor):02d}{int(micro):02d}"
31+
if version > "080699":
32+
raise unittest.SkipTest(f"Tk version {major}.{minor}.{micro} not supported")
2233

2334
def load_tests(*args):
2435
return load_package_tests(os.path.dirname(__file__), *args)

Lib/test/test_ttk/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,21 @@
1313
# Skip test if tk cannot be initialized.
1414
support.requires('gui')
1515

16+
# Skip test if tk version is too new.
17+
support.check_tk_version()
1618

1719
import tkinter
1820
from _tkinter import TclError
1921
from tkinter import ttk
2022

2123

24+
tcl = tkinter.Tcl()
25+
major, minor, micro = tcl.call("info", "patchlevel").split(".")
26+
version = f"{int(major):02d}{int(minor):02d}{int(micro):02d}"
27+
if version > "080699":
28+
raise unittest.SkipTest(f"Tk version {major}.{minor}.{micro} not supported")
29+
30+
2231
def setUpModule():
2332
root = None
2433
try:

Lib/test/test_ttk_textonly.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
from test.support import import_helper
1+
from test.support import import_helper, check_tk_version
22

33
# Skip this test if _tkinter does not exist.
44
import_helper.import_module('_tkinter')
55

6+
check_tk_version()
7+
68
import unittest
79
from tkinter import ttk
810

0 commit comments

Comments
 (0)