Skip to content
Merged
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
3 changes: 3 additions & 0 deletions Lib/test/libregrtest/cmdline.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -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'.
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/libregrtest/utils.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_tcl.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -817,6 +817,10 @@ def test_huge_string_builtins2(self, size):


defsetUpModule():
wantobjects=support.get_resource_value('wantobjects')
ifwantobjectsisnotNone:
unittest.enterModuleContext(
support.swap_attr(tkinter, 'wantobjects', int(wantobjects)))
ifsupport.verbose:
tcl=Tcl()
print('patchlevel =', tcl.call('info', 'patchlevel'), flush=True)
Expand Down
6 changes: 6 additions & 0 deletions Lib/test/test_tkinter/__init__.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,3 +22,9 @@

defload_tests(*args):
returnload_package_tests(os.path.dirname(__file__), *args)

defsetUpModule():
wantobjects=support.get_resource_value('wantobjects')
ifwantobjectsisnotNone:
unittest.enterModuleContext(
support.swap_attr(tkinter, 'wantobjects', int(wantobjects)))
11 changes: 11 additions & 0 deletions Lib/test/test_tkinter/support.py
Original file line numberDiff line numberDiff line change
@@ -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:

Expand All@@ -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')
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_colorchooser.py
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
importunittest
importtkinter
fromtest.supportimportrequires, swap_attr
fromtest.test_tkinter.supportimportsetUpModule# noqa: F401
fromtest.test_tkinter.supportimportAbstractDefaultRootTest, AbstractTkTest
fromtkinterimportcolorchooser
fromtkinter.colorchooserimportaskcolor
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_font.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,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')
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_geometry_managers.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -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

Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_images.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,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')
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_loadtk.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@
importunittest
importtest.supportastest_support
fromtest.supportimportos_helper
fromtest.test_tkinter.supportimportsetUpModule# noqa: F401
fromtkinterimportTcl, TclError

test_support.requires('gui')
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_messagebox.py
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
importunittest
importtkinter
fromtest.supportimportrequires, swap_attr
fromtest.test_tkinter.supportimportsetUpModule# noqa: F401
fromtest.test_tkinter.supportimportAbstractDefaultRootTest
fromtkinter.commondialogimportDialog
fromtkinter.messageboximportshowinfo
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_misc.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,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)

Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_simpledialog.py
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
importunittest
importtkinter
fromtest.supportimportrequires, swap_attr
fromtest.test_tkinter.supportimportsetUpModule# noqa: F401
fromtest.test_tkinter.supportimportAbstractDefaultRootTest
fromtkinter.simpledialogimportDialog, askinteger

Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_text.py
Original file line numberDiff line numberDiff line change
@@ -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')
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_variables.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,7 @@
fromtkinterimport (Variable, StringVar, IntVar, DoubleVar, BooleanVar, Tcl,
TclError)
fromtest.supportimportALWAYS_EQ
fromtest.test_tkinter.supportimportsetUpModule# noqa: F401
fromtest.test_tkinter.supportimportAbstractDefaultRootTest, tcl_version


Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_widgets.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_ttk/__init__.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,10 @@


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()
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_ttk/test_extensions.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@
importtkinter
fromtkinterimportttk
fromtest.supportimportrequires, gc_collect
fromtest.test_tkinter.supportimportsetUpModule# noqa: F401
fromtest.test_tkinter.supportimportAbstractTkTest, AbstractDefaultRootTest

requires('gui')
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_ttk/test_style.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,7 @@
fromtkinterimportTclError
fromtestimportsupport
fromtest.supportimportrequires
fromtest.test_tkinter.supportimportsetUpModule# noqa: F401
fromtest.test_tkinter.supportimportAbstractTkTest, get_tk_patchlevel

requires('gui')
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_ttk/test_widgets.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,7 @@
importsys

fromtest.test_ttk_textonlyimportMockTclObj
fromtest.test_tkinter.supportimportsetUpModule# noqa: F401
fromtest.test_tkinter.supportimport (
AbstractTkTest, requires_tk, tk_version, get_tk_patchlevel,
simulate_mouse_click, AbstractDefaultRootTest)
Expand Down
Original file line numberDiff line numberDiff line change
@@ -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``.
Loading