mirror of
https://github.com/python/cpython.git
synced 2026-01-26 21:03:34 +00:00
[3.14] gh-65784: Add support for parametrized resource wantobjects in regrtests (GH-143570) (GH-143913)
This allows to run Tkinter tests with the specified value of tkinter.wantobjects, for example "-u wantobjects=0". (cherry picked from commit 21ed1e2a9401a2e96ccc910fcb66f22afc96efbd) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
0042384bd5
commit
94ae09273e
@ -134,6 +134,9 @@ resources to test. Currently only the following are defined:
|
||||
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'.
|
||||
|
||||
@ -41,7 +41,7 @@ ALL_RESOURCES = ('audio', 'console', 'curses', 'largefile', 'network',
|
||||
# - 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
|
||||
|
||||
@ -817,6 +817,10 @@ class BigmemTclTest(unittest.TestCase):
|
||||
|
||||
|
||||
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)
|
||||
|
||||
@ -22,3 +22,9 @@ requires('gui')
|
||||
|
||||
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)))
|
||||
|
||||
@ -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 @@ class AbstractTkTest:
|
||||
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')
|
||||
|
||||
@ -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
|
||||
|
||||
@ -2,6 +2,7 @@ import unittest
|
||||
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')
|
||||
|
||||
@ -4,6 +4,7 @@ import tkinter
|
||||
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
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ import unittest
|
||||
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')
|
||||
|
||||
@ -3,6 +3,7 @@ import sys
|
||||
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')
|
||||
|
||||
@ -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
|
||||
|
||||
@ -4,6 +4,7 @@ import tkinter
|
||||
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)
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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')
|
||||
|
||||
@ -6,6 +6,7 @@ import tkinter
|
||||
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
|
||||
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ from tkinter import TclError
|
||||
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)
|
||||
|
||||
@ -20,6 +20,10 @@ from tkinter import ttk
|
||||
|
||||
|
||||
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()
|
||||
|
||||
@ -3,6 +3,7 @@ import unittest
|
||||
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')
|
||||
|
||||
@ -5,6 +5,7 @@ from tkinter import ttk
|
||||
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')
|
||||
|
||||
@ -5,6 +5,7 @@ from test.support import requires, gc_collect
|
||||
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)
|
||||
|
||||
@ -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…
x
Reference in New Issue
Block a user