Skip to content
Open
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
13 changes: 13 additions & 0 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2992,3 +2992,16 @@ def is_libssl_fips_mode():
except ImportError:
return False # more of a maybe, unless we add this to the _ssl module.
return get_fips_mode() != 0


def check_tk_version():
from .import_helper import import_module
import_module('_tkinter')
import tkinter
tcl = tkinter.Tcl()
major, minor, micro = tcl.call("info", "patchlevel").split(".")
version = f"{int(major):02d}{int(minor):02d}{int(micro):02d}"
# update max version number as necessary
if version > "080699":
raise unittest.SkipTest(f"Tk version {major}.{minor}.{micro}"
" not supported")
11 changes: 11 additions & 0 deletions Lib/test/test_tkinter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import_helper,
load_package_tests,
requires,
check_tk_version,
)


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

# Skip test if tk version is too new.
check_tk_version()


import tkinter
tcl = tkinter.Tcl()
major, minor, micro = tcl.call("info", "patchlevel").split(".")
version = f"{int(major):02d}{int(minor):02d}{int(micro):02d}"
if version > "080699":
raise unittest.SkipTest(f"Tk version {major}.{minor}.{micro} not supported")

def load_tests(*args):
return load_package_tests(os.path.dirname(__file__), *args)
9 changes: 9 additions & 0 deletions Lib/test/test_ttk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,21 @@
# Skip test if tk cannot be initialized.
support.requires('gui')

# Skip test if tk version is too new.
support.check_tk_version()

import tkinter
from _tkinter import TclError
from tkinter import ttk


tcl = tkinter.Tcl()
major, minor, micro = tcl.call("info", "patchlevel").split(".")
version = f"{int(major):02d}{int(minor):02d}{int(micro):02d}"
if version > "080699":
raise unittest.SkipTest(f"Tk version {major}.{minor}.{micro} not supported")


def setUpModule():
root = None
try:
Expand Down
4 changes: 3 additions & 1 deletion Lib/test/test_ttk_textonly.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from test.support import import_helper
from test.support import import_helper, check_tk_version

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

check_tk_version()

import unittest
from tkinter import ttk

Expand Down
Loading