mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-104496: Use correct Tcl or Tk version in Tkinter tests (GH-107688)
In future Tcl and Tk versions can be desynchronized.
This commit is contained in:
parent
6925c578a0
commit
3c8e8f3cee
7 changed files with 30 additions and 39 deletions
|
@ -79,28 +79,28 @@ def simulate_mouse_click(widget, x, y):
|
|||
|
||||
import _tkinter
|
||||
tcl_version = tuple(map(int, _tkinter.TCL_VERSION.split('.')))
|
||||
tk_version = tuple(map(int, _tkinter.TK_VERSION.split('.')))
|
||||
|
||||
def requires_tcl(*version):
|
||||
if len(version) <= 2:
|
||||
return unittest.skipUnless(tcl_version >= version,
|
||||
'requires Tcl version >= ' + '.'.join(map(str, version)))
|
||||
def requires_tk(*version):
|
||||
if len(version) <= 2 and tk_version >= version:
|
||||
return lambda test: test
|
||||
|
||||
def deco(test):
|
||||
@functools.wraps(test)
|
||||
def newtest(self):
|
||||
if get_tk_patchlevel() < version:
|
||||
self.skipTest('requires Tcl version >= ' +
|
||||
root = getattr(self, 'root', None)
|
||||
if get_tk_patchlevel(root) < version:
|
||||
self.skipTest('requires Tk version >= ' +
|
||||
'.'.join(map(str, version)))
|
||||
test(self)
|
||||
return newtest
|
||||
return deco
|
||||
|
||||
_tk_patchlevel = None
|
||||
def get_tk_patchlevel():
|
||||
def get_tk_patchlevel(root):
|
||||
global _tk_patchlevel
|
||||
if _tk_patchlevel is None:
|
||||
tcl = tkinter.Tcl()
|
||||
_tk_patchlevel = tcl.info_patchlevel()
|
||||
_tk_patchlevel = tkinter._parse_version(root.tk.globalgetvar('tk_patchLevel'))
|
||||
return _tk_patchlevel
|
||||
|
||||
units = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue