https://github.com/python/cpython/commit/21ed1e2a9401a2e96ccc910fcb66f22afc96efbd
commit: 21ed1e2a9401a2e96ccc910fcb66f22afc96efbd
branch: main
author: Serhiy Storchaka <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-01-16T18:38:38+02:00
summary:
gh-65784: Add support for parametrized resource wantobjects in regrtests
(GH-143570)
This allows to run Tkinter tests with the specified value of
tkinter.wantobjects, for example "-u wantobjects=0".
files:
A Misc/NEWS.d/next/Tests/2026-01-08-16-56-59.gh-issue-65784.aKNo1U.rst
M Lib/test/libregrtest/cmdline.py
M Lib/test/libregrtest/utils.py
M Lib/test/test_tcl.py
M Lib/test/test_tkinter/__init__.py
M Lib/test/test_tkinter/support.py
M Lib/test/test_tkinter/test_colorchooser.py
M Lib/test/test_tkinter/test_font.py
M Lib/test/test_tkinter/test_geometry_managers.py
M Lib/test/test_tkinter/test_images.py
M Lib/test/test_tkinter/test_loadtk.py
M Lib/test/test_tkinter/test_messagebox.py
M Lib/test/test_tkinter/test_misc.py
M Lib/test/test_tkinter/test_simpledialog.py
M Lib/test/test_tkinter/test_text.py
M Lib/test/test_tkinter/test_variables.py
M Lib/test/test_tkinter/test_widgets.py
M Lib/test/test_ttk/__init__.py
M Lib/test/test_ttk/test_extensions.py
M Lib/test/test_ttk/test_style.py
M Lib/test/test_ttk/test_widgets.py
diff --git a/Lib/test/libregrtest/cmdline.py b/Lib/test/libregrtest/cmdline.py
index d784506703461b..2c404f6d80bcf3 100644
--- a/Lib/test/libregrtest/cmdline.py
+++ b/Lib/test/libregrtest/cmdline.py
@@ -134,6 +134,9 @@
and 3.9 to test backwards compatibility. These tests
may take very long to complete.
+ wantobjects - Allows to run Tkinter tests with the specified value of
+ tkinter.wantobjects.
+
To enable all resources except one, use '-uall,-<resource>'. For
example, to run all the tests except for the gui tests, give the
option '-uall,-gui'.
diff --git a/Lib/test/libregrtest/utils.py b/Lib/test/libregrtest/utils.py
index 4479f336b1ee53..3bbc3fa127abb3 100644
--- a/Lib/test/libregrtest/utils.py
+++ b/Lib/test/libregrtest/utils.py
@@ -41,7 +41,7 @@
# - tzdata: while needed to validate fully test_datetime, it makes
# test_datetime too slow (15-20 min on some buildbots) and so is disabled by
# default (see bpo-30822).
-RESOURCE_NAMES = ALL_RESOURCES + ('extralargefile', 'tzdata', 'xpickle')
+RESOURCE_NAMES = ALL_RESOURCES + ('extralargefile', 'tzdata', 'xpickle',
'wantobjects')
# Types for types hints
diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py
index ef281f6d1fe53a..47450d3fd5976f 100644
--- a/Lib/test/test_tcl.py
+++ b/Lib/test/test_tcl.py
@@ -817,6 +817,10 @@ def test_huge_string_builtins2(self, size):
def setUpModule():
+ wantobjects = support.get_resource_value('wantobjects')
+ if wantobjects is not None:
+ unittest.enterModuleContext(
+ support.swap_attr(tkinter, 'wantobjects', int(wantobjects)))
if support.verbose:
tcl = Tcl()
print('patchlevel =', tcl.call('info', 'patchlevel'), flush=True)
diff --git a/Lib/test/test_tkinter/__init__.py
b/Lib/test/test_tkinter/__init__.py
index aa196c12c804ac..62890c705a6ca6 100644
--- a/Lib/test/test_tkinter/__init__.py
+++ b/Lib/test/test_tkinter/__init__.py
@@ -22,3 +22,9 @@
def load_tests(*args):
return load_package_tests(os.path.dirname(__file__), *args)
+
+def setUpModule():
+ wantobjects = support.get_resource_value('wantobjects')
+ if wantobjects is not None:
+ unittest.enterModuleContext(
+ support.swap_attr(tkinter, 'wantobjects', int(wantobjects)))
diff --git a/Lib/test/test_tkinter/support.py b/Lib/test/test_tkinter/support.py
index 46b01e6f131290..7fb0b217fd24ec 100644
--- a/Lib/test/test_tkinter/support.py
+++ b/Lib/test/test_tkinter/support.py
@@ -1,5 +1,14 @@
import functools
import tkinter
+import unittest
+from test import support
+
+
+def setUpModule():
+ wantobjects = support.get_resource_value('wantobjects')
+ if wantobjects is not None:
+ unittest.enterModuleContext(
+ support.swap_attr(tkinter, 'wantobjects', int(wantobjects)))
class AbstractTkTest:
@@ -10,6 +19,8 @@ def setUpClass(cls):
tkinter.NoDefaultRoot()
cls.root = tkinter.Tk()
cls.wantobjects = cls.root.wantobjects()
+ if support.is_resource_enabled('wantobjects'):
+ assert cls.wantobjects ==
int(support.get_resource_value('wantobjects'))
# De-maximize main window.
# Some window managers can maximize new windows.
cls.root.wm_state('normal')
diff --git a/Lib/test/test_tkinter/test_colorchooser.py
b/Lib/test/test_tkinter/test_colorchooser.py
index 9bba21392d8d14..8a7e97f207a41f 100644
--- a/Lib/test/test_tkinter/test_colorchooser.py
+++ b/Lib/test/test_tkinter/test_colorchooser.py
@@ -1,6 +1,7 @@
import unittest
import tkinter
from test.support import requires, swap_attr
+from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import AbstractDefaultRootTest, AbstractTkTest
from tkinter import colorchooser
from tkinter.colorchooser import askcolor
diff --git a/Lib/test/test_tkinter/test_font.py
b/Lib/test/test_tkinter/test_font.py
index fc50f9fdbb588c..ee147710fbfc85 100644
--- a/Lib/test/test_tkinter/test_font.py
+++ b/Lib/test/test_tkinter/test_font.py
@@ -3,6 +3,7 @@
import tkinter
from tkinter import font
from test.support import requires, gc_collect, ALWAYS_EQ
+from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest
requires('gui')
diff --git a/Lib/test/test_tkinter/test_geometry_managers.py
b/Lib/test/test_tkinter/test_geometry_managers.py
index d71a634a767310..b2ce143ff0948f 100644
--- a/Lib/test/test_tkinter/test_geometry_managers.py
+++ b/Lib/test/test_tkinter/test_geometry_managers.py
@@ -4,6 +4,7 @@
from tkinter import TclError
from test.support import requires
+from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import pixels_conv
from test.test_tkinter.widget_tests import AbstractWidgetTest
diff --git a/Lib/test/test_tkinter/test_images.py
b/Lib/test/test_tkinter/test_images.py
index 358a18beee2571..3aca9515a33b24 100644
--- a/Lib/test/test_tkinter/test_images.py
+++ b/Lib/test/test_tkinter/test_images.py
@@ -3,6 +3,7 @@
import tkinter
from test import support
from test.support import os_helper
+from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest,
requires_tk
support.requires('gui')
diff --git a/Lib/test/test_tkinter/test_loadtk.py
b/Lib/test/test_tkinter/test_loadtk.py
index 61b0eda2fc750a..7cff654621eb35 100644
--- a/Lib/test/test_tkinter/test_loadtk.py
+++ b/Lib/test/test_tkinter/test_loadtk.py
@@ -3,6 +3,7 @@
import unittest
import test.support as test_support
from test.support import os_helper
+from test.test_tkinter.support import setUpModule # noqa: F401
from tkinter import Tcl, TclError
test_support.requires('gui')
diff --git a/Lib/test/test_tkinter/test_messagebox.py
b/Lib/test/test_tkinter/test_messagebox.py
index f41bdc98286283..f29f0c7ba59086 100644
--- a/Lib/test/test_tkinter/test_messagebox.py
+++ b/Lib/test/test_tkinter/test_messagebox.py
@@ -1,6 +1,7 @@
import unittest
import tkinter
from test.support import requires, swap_attr
+from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import AbstractDefaultRootTest
from tkinter.commondialog import Dialog
from tkinter.messagebox import showinfo
diff --git a/Lib/test/test_tkinter/test_misc.py
b/Lib/test/test_tkinter/test_misc.py
index 32e2329506e7ff..a6ba55b3fcadb3 100644
--- a/Lib/test/test_tkinter/test_misc.py
+++ b/Lib/test/test_tkinter/test_misc.py
@@ -5,6 +5,7 @@
from tkinter import TclError
import enum
from test import support
+from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import (AbstractTkTest, AbstractDefaultRootTest,
requires_tk, get_tk_patchlevel)
diff --git a/Lib/test/test_tkinter/test_simpledialog.py
b/Lib/test/test_tkinter/test_simpledialog.py
index 502f7f7098a322..313ad82e0a2c0d 100644
--- a/Lib/test/test_tkinter/test_simpledialog.py
+++ b/Lib/test/test_tkinter/test_simpledialog.py
@@ -1,6 +1,7 @@
import unittest
import tkinter
from test.support import requires, swap_attr
+from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import AbstractDefaultRootTest
from tkinter.simpledialog import Dialog, askinteger
diff --git a/Lib/test/test_tkinter/test_text.py
b/Lib/test/test_tkinter/test_text.py
index d579cca95ee2bb..453a4505a0a4da 100644
--- a/Lib/test/test_tkinter/test_text.py
+++ b/Lib/test/test_tkinter/test_text.py
@@ -1,6 +1,7 @@
import unittest
import tkinter
from test.support import requires
+from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import AbstractTkTest
requires('gui')
diff --git a/Lib/test/test_tkinter/test_variables.py
b/Lib/test/test_tkinter/test_variables.py
index 75b3a6934fc0e3..8733095ffb65f4 100644
--- a/Lib/test/test_tkinter/test_variables.py
+++ b/Lib/test/test_tkinter/test_variables.py
@@ -6,6 +6,7 @@
from tkinter import (Variable, StringVar, IntVar, DoubleVar, BooleanVar, Tcl,
TclError)
from test.support import ALWAYS_EQ
+from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import AbstractDefaultRootTest, tcl_version
diff --git a/Lib/test/test_tkinter/test_widgets.py
b/Lib/test/test_tkinter/test_widgets.py
index 20e385ad0b660c..f3579a23afc539 100644
--- a/Lib/test/test_tkinter/test_widgets.py
+++ b/Lib/test/test_tkinter/test_widgets.py
@@ -4,6 +4,7 @@
import os
from test.support import requires
+from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import (requires_tk, tk_version,
get_tk_patchlevel, widget_eq,
AbstractDefaultRootTest)
diff --git a/Lib/test/test_ttk/__init__.py b/Lib/test/test_ttk/__init__.py
index 4a077a0f966fbb..7a47f44ca38221 100644
--- a/Lib/test/test_ttk/__init__.py
+++ b/Lib/test/test_ttk/__init__.py
@@ -30,6 +30,10 @@ def test_deprecated__version__(self):
def setUpModule():
+ wantobjects = support.get_resource_value('wantobjects')
+ if wantobjects is not None:
+ unittest.enterModuleContext(
+ support.swap_attr(tkinter, 'wantobjects', int(wantobjects)))
root = None
try:
root = tkinter.Tk()
diff --git a/Lib/test/test_ttk/test_extensions.py
b/Lib/test/test_ttk/test_extensions.py
index 05bca59e703936..669a3e184eb771 100644
--- a/Lib/test/test_ttk/test_extensions.py
+++ b/Lib/test/test_ttk/test_extensions.py
@@ -3,6 +3,7 @@
import tkinter
from tkinter import ttk
from test.support import requires, gc_collect
+from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest
requires('gui')
diff --git a/Lib/test/test_ttk/test_style.py b/Lib/test/test_ttk/test_style.py
index 19918772514ad4..fdbaae1b644e4d 100644
--- a/Lib/test/test_ttk/test_style.py
+++ b/Lib/test/test_ttk/test_style.py
@@ -5,6 +5,7 @@
from tkinter import TclError
from test import support
from test.support import requires
+from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import AbstractTkTest, get_tk_patchlevel
requires('gui')
diff --git a/Lib/test/test_ttk/test_widgets.py
b/Lib/test/test_ttk/test_widgets.py
index f33da2a8848738..e738fbff82ed43 100644
--- a/Lib/test/test_ttk/test_widgets.py
+++ b/Lib/test/test_ttk/test_widgets.py
@@ -5,6 +5,7 @@
import sys
from test.test_ttk_textonly import MockTclObj
+from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import (
AbstractTkTest, requires_tk, tk_version, get_tk_patchlevel,
simulate_mouse_click, AbstractDefaultRootTest)
diff --git
a/Misc/NEWS.d/next/Tests/2026-01-08-16-56-59.gh-issue-65784.aKNo1U.rst
b/Misc/NEWS.d/next/Tests/2026-01-08-16-56-59.gh-issue-65784.aKNo1U.rst
new file mode 100644
index 00000000000000..7d1a153fc7a6ca
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2026-01-08-16-56-59.gh-issue-65784.aKNo1U.rst
@@ -0,0 +1,3 @@
+Add support for parametrized resource ``wantobjects`` in regrtests,
+which allows to run Tkinter tests with the specified value of
+:data:`!tkinter.wantobjects`, for example ``-u wantobjects=0``.
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]