gh-54781: Move Lib/tkinter/test/test_ttk/ to Lib/test/test_ttk/ (#94070)

* Move Lib/tkinter/test/test_tkinter/ to Lib/test/test_tkinter/.
* Move Lib/tkinter/test/test_ttk/ to Lib/test/test_ttk/.
* Add Lib/test/test_ttk/__init__.py based on test_ttk_guionly.py.
* Add Lib/test/test_tkinter/__init__.py
* Remove old Lib/test/test_tk.py.
* Remove old Lib/test/test_ttk_guionly.py.
* Add __main__ sub-modules.
* Update imports and update references to rename files.
This commit is contained in:
Victor Stinner 2022-06-22 22:23:37 +02:00 committed by GitHub
parent 47e35625ff
commit c1fb12e5af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 100 additions and 109 deletions

View File

@ -1,20 +0,0 @@
import unittest
from test import support
from test.support import import_helper
from test.support import check_sanitizer
if check_sanitizer(address=True, memory=True):
raise unittest.SkipTest("Tests involvin libX11 can SEGFAULT on ASAN/MSAN builds")
# Skip test if _tkinter wasn't built.
import_helper.import_module('_tkinter')
# Skip test if tk cannot be initialized.
support.requires('gui')
def load_tests(loader, tests, pattern):
return loader.discover('tkinter.test.test_tkinter')
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,18 @@
import os.path
import unittest
from test import support
from test.support import import_helper
if support.check_sanitizer(address=True, memory=True):
raise unittest.SkipTest("Tests involving libX11 can SEGFAULT on ASAN/MSAN builds")
# Skip test if _tkinter wasn't built.
import_helper.import_module('_tkinter')
# Skip test if tk cannot be initialized.
support.requires('gui')
def load_tests(*args):
return support.load_package_tests(os.path.dirname(__file__), *args)

View File

@ -0,0 +1,4 @@
from . import load_tests
import unittest
unittest.main()

View File

@ -1,7 +1,7 @@
import unittest
import tkinter
from test.support import requires, swap_attr
from tkinter.test.support import AbstractDefaultRootTest, AbstractTkTest
from test.test_tkinter.support import AbstractDefaultRootTest, AbstractTkTest
from tkinter import colorchooser
from tkinter.colorchooser import askcolor
from tkinter.commondialog import Dialog

View File

@ -2,7 +2,7 @@ import unittest
import tkinter
from tkinter import font
from test.support import requires, gc_collect, ALWAYS_EQ
from tkinter.test.support import AbstractTkTest, AbstractDefaultRootTest
from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest
requires('gui')

View File

@ -4,8 +4,8 @@ import tkinter
from tkinter import TclError
from test.support import requires
from tkinter.test.support import pixels_conv
from tkinter.test.widget_tests import AbstractWidgetTest
from test.test_tkinter.support import pixels_conv
from test.test_tkinter.widget_tests import AbstractWidgetTest
requires('gui')

View File

@ -2,7 +2,7 @@ import unittest
import tkinter
from test import support
from test.support import os_helper
from tkinter.test.support import AbstractTkTest, AbstractDefaultRootTest, requires_tcl
from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest, requires_tcl
support.requires('gui')

View File

@ -1,7 +1,7 @@
import unittest
import tkinter
from test.support import requires, swap_attr
from tkinter.test.support import AbstractDefaultRootTest
from test.test_tkinter.support import AbstractDefaultRootTest
from tkinter.commondialog import Dialog
from tkinter.messagebox import showinfo

View File

@ -3,7 +3,7 @@ import unittest
import tkinter
import enum
from test import support
from tkinter.test.support import AbstractTkTest, AbstractDefaultRootTest
from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest
support.requires('gui')

View File

@ -1,7 +1,7 @@
import unittest
import tkinter
from test.support import requires, swap_attr
from tkinter.test.support import AbstractDefaultRootTest
from test.test_tkinter.support import AbstractDefaultRootTest
from tkinter.simpledialog import Dialog, askinteger
requires('gui')

View File

@ -1,7 +1,7 @@
import unittest
import tkinter
from test.support import requires
from tkinter.test.support import AbstractTkTest
from test.test_tkinter.support import AbstractTkTest
requires('gui')

View File

@ -6,7 +6,7 @@ import tkinter
from tkinter import (Variable, StringVar, IntVar, DoubleVar, BooleanVar, Tcl,
TclError)
from test.support import ALWAYS_EQ
from tkinter.test.support import AbstractDefaultRootTest
from test.test_tkinter.support import AbstractDefaultRootTest
class Var(Variable):

View File

@ -4,10 +4,10 @@ from tkinter import TclError
import os
from test.support import requires
from tkinter.test.support import (requires_tcl,
from test.test_tkinter.support import (requires_tcl,
get_tk_patchlevel, widget_eq,
AbstractDefaultRootTest)
from tkinter.test.widget_tests import (
from test.test_tkinter.widget_tests import (
add_standard_options,
AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests,
setUpModule)

View File

@ -1,7 +1,7 @@
# Common tests for test_tkinter/test_widgets.py and test_ttk/test_widgets.py
import tkinter
from tkinter.test.support import (AbstractTkTest, tcl_version,
from test.test_tkinter.support import (AbstractTkTest, tcl_version,
pixels_conv, tcl_obj_eq)
import test.support

View File

@ -1,10 +1,11 @@
import os.path
import unittest
from test import support
from test.support import import_helper
from test.support import check_sanitizer
if check_sanitizer(address=True, memory=True):
raise unittest.SkipTest("Tests involvin libX11 can SEGFAULT on ASAN/MSAN builds")
if support.check_sanitizer(address=True, memory=True):
raise unittest.SkipTest("Tests involving libX11 can SEGFAULT on ASAN/MSAN builds")
# Skip this test if _tkinter wasn't built.
import_helper.import_module('_tkinter')
@ -12,6 +13,7 @@ import_helper.import_module('_tkinter')
# Skip test if tk cannot be initialized.
support.requires('gui')
import tkinter
from _tkinter import TclError
from tkinter import ttk
@ -32,9 +34,6 @@ def setUpModule():
root.destroy()
del root
def load_tests(loader, tests, pattern):
return loader.discover('tkinter.test.test_ttk')
if __name__ == '__main__':
unittest.main()
def load_tests(*args):
return support.load_package_tests(os.path.dirname(__file__), *args)

View File

@ -0,0 +1,4 @@
from . import load_tests
import unittest
unittest.main()

View File

@ -3,7 +3,7 @@ import unittest
import tkinter
from tkinter import ttk
from test.support import requires, gc_collect
from tkinter.test.support import AbstractTkTest, AbstractDefaultRootTest
from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest
requires('gui')

View File

@ -4,7 +4,7 @@ import tkinter
from tkinter import ttk
from test import support
from test.support import requires
from tkinter.test.support import AbstractTkTest, get_tk_patchlevel
from test.test_tkinter.support import AbstractTkTest, get_tk_patchlevel
requires('gui')

View File

@ -5,9 +5,9 @@ from test.support import requires, gc_collect
import sys
from test.test_ttk_textonly import MockTclObj
from tkinter.test.support import (AbstractTkTest, tcl_version, get_tk_patchlevel,
from test.test_tkinter.support import (AbstractTkTest, tcl_version, get_tk_patchlevel,
simulate_mouse_click, AbstractDefaultRootTest)
from tkinter.test.widget_tests import (add_standard_options,
from test.test_tkinter.widget_tests import (add_standard_options,
AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests,
setUpModule)

View File

@ -1987,15 +1987,15 @@ TESTSUBDIRS= distutils/tests \
test/test_lib2to3/data/fixers \
test/test_lib2to3/data/fixers/myfixes \
test/test_peg_generator \
test/test_tkinter \
test/test_tools \
test/test_ttk \
test/test_warnings test/test_warnings/data \
test/test_zoneinfo test/test_zoneinfo/data \
test/test_unittest test/test_unittest/testmock \
test/tracedmodules \
test/xmltestdata test/xmltestdata/c14n-20 \
test/ziptestdata \
tkinter/test tkinter/test/test_tkinter \
tkinter/test/test_ttk
test/ziptestdata
TEST_MODULES=@TEST_MODULES@
libinstall: all $(srcdir)/Modules/xxmodule.c

View File

@ -0,0 +1,2 @@
Rename test_tk to test_tkinter, and rename test_ttk_guionly to test_ttk.
Patch by Victor Stinner.

View File

@ -1323,7 +1323,17 @@
<Compile Include="test\test_timeit.py" />
<Compile Include="test\test_timeout.py" />
<Compile Include="test\test_tix.py" />
<Compile Include="test\test_tk.py" />
<Compile Include="test\test_tkinter\__init__.py" />
<Compile Include="test\test_tkinter\support.py" />
<Compile Include="test\test_tkinter\test_font.py" />
<Compile Include="test\test_tkinter\test_geometry_managers.py" />
<Compile Include="test\test_tkinter\test_images.py" />
<Compile Include="test\test_tkinter\test_loadtk.py" />
<Compile Include="test\test_tkinter\test_misc.py" />
<Compile Include="test\test_tkinter\test_text.py" />
<Compile Include="test\test_tkinter\test_variables.py" />
<Compile Include="test\test_tkinter\test_widgets.py" />
<Compile Include="test\test_tkinter\widget_tests.py" />
<Compile Include="test\test_tokenize.py" />
<Compile Include="test\test_tools\test_fixcid.py" />
<Compile Include="test\test_tools\test_gprof2html.py" />
@ -1339,8 +1349,11 @@
<Compile Include="test\test_trace.py" />
<Compile Include="test\test_traceback.py" />
<Compile Include="test\test_tracemalloc.py" />
<Compile Include="test\test_ttk_guionly.py" />
<Compile Include="test\test_ttk_textonly.py" />
<Compile Include="test\test_ttk\__init__.py" />
<Compile Include="test\test_ttk\test_extensions.py" />
<Compile Include="test\test_ttk\test_style.py" />
<Compile Include="test\test_ttk\test_widgets.py" />
<Compile Include="test\test_tuple.py" />
<Compile Include="test\test_turtle.py" />
<Compile Include="test\test_typechecks.py" />
@ -1353,7 +1366,33 @@
<Compile Include="test\test_unicode_file.py" />
<Compile Include="test\test_unicode_file_functions.py" />
<Compile Include="test\test_unicode_identifiers.py" />
<Compile Include="test\test_unittest.py" />
<Compile Include="test\test_unittest\dummy.py" />
<Compile Include="test\test_unittest\support.py" />
<Compile Include="test\test_unittest\testmock\support.py" />
<Compile Include="test\test_unittest\testmock\testcallable.py" />
<Compile Include="test\test_unittest\testmock\testhelpers.py" />
<Compile Include="test\test_unittest\testmock\testmagicmethods.py" />
<Compile Include="test\test_unittest\testmock\testmock.py" />
<Compile Include="test\test_unittest\testmock\testpatch.py" />
<Compile Include="test\test_unittest\testmock\testsentinel.py" />
<Compile Include="test\test_unittest\testmock\testwith.py" />
<Compile Include="test\test_unittest\testmock\__init__.py" />
<Compile Include="test\test_unittest\testmock\__main__.py" />
<Compile Include="test\test_unittest\test_assertions.py" />
<Compile Include="test\test_unittest\test_break.py" />
<Compile Include="test\test_unittest\test_case.py" />
<Compile Include="test\test_unittest\test_discovery.py" />
<Compile Include="test\test_unittest\test_functiontestcase.py" />
<Compile Include="test\test_unittest\test_loader.py" />
<Compile Include="test\test_unittest\test_program.py" />
<Compile Include="test\test_unittest\test_result.py" />
<Compile Include="test\test_unittest\test_runner.py" />
<Compile Include="test\test_unittest\test_setups.py" />
<Compile Include="test\test_unittest\test_skipping.py" />
<Compile Include="test\test_unittest\test_suite.py" />
<Compile Include="test\test_unittest\_test_warnings.py" />
<Compile Include="test\test_unittest\__init__.py" />
<Compile Include="test\test_unittest\__main__.py" />
<Compile Include="test\test_univnewlines.py" />
<Compile Include="test\test_unpack.py" />
<Compile Include="test\test_unpack_ex.py" />
@ -1432,22 +1471,6 @@
<Compile Include="tkinter\messagebox.py" />
<Compile Include="tkinter\scrolledtext.py" />
<Compile Include="tkinter\simpledialog.py" />
<Compile Include="tkinter\test\support.py" />
<Compile Include="tkinter\test\test_tkinter\test_font.py" />
<Compile Include="tkinter\test\test_tkinter\test_geometry_managers.py" />
<Compile Include="tkinter\test\test_tkinter\test_images.py" />
<Compile Include="tkinter\test\test_tkinter\test_loadtk.py" />
<Compile Include="tkinter\test\test_tkinter\test_misc.py" />
<Compile Include="tkinter\test\test_tkinter\test_text.py" />
<Compile Include="tkinter\test\test_tkinter\test_variables.py" />
<Compile Include="tkinter\test\test_tkinter\test_widgets.py" />
<Compile Include="tkinter\test\test_tkinter\__init__.py" />
<Compile Include="tkinter\test\test_ttk\test_extensions.py" />
<Compile Include="tkinter\test\test_ttk\test_style.py" />
<Compile Include="tkinter\test\test_ttk\test_widgets.py" />
<Compile Include="tkinter\test\test_ttk\__init__.py" />
<Compile Include="tkinter\test\widget_tests.py" />
<Compile Include="tkinter\test\__init__.py" />
<Compile Include="tkinter\tix.py" />
<Compile Include="tkinter\ttk.py" />
<Compile Include="tkinter\__init__.py" />
@ -1490,33 +1513,6 @@
<Compile Include="unittest\runner.py" />
<Compile Include="unittest\signals.py" />
<Compile Include="unittest\suite.py" />
<Compile Include="test\test_unittest\dummy.py" />
<Compile Include="test\test_unittest\support.py" />
<Compile Include="test\test_unittest\testmock\support.py" />
<Compile Include="test\test_unittest\testmock\testcallable.py" />
<Compile Include="test\test_unittest\testmock\testhelpers.py" />
<Compile Include="test\test_unittest\testmock\testmagicmethods.py" />
<Compile Include="test\test_unittest\testmock\testmock.py" />
<Compile Include="test\test_unittest\testmock\testpatch.py" />
<Compile Include="test\test_unittest\testmock\testsentinel.py" />
<Compile Include="test\test_unittest\testmock\testwith.py" />
<Compile Include="test\test_unittest\testmock\__init__.py" />
<Compile Include="test\test_unittest\testmock\__main__.py" />
<Compile Include="test\test_unittest\test_assertions.py" />
<Compile Include="test\test_unittest\test_break.py" />
<Compile Include="test\test_unittest\test_case.py" />
<Compile Include="test\test_unittest\test_discovery.py" />
<Compile Include="test\test_unittest\test_functiontestcase.py" />
<Compile Include="test\test_unittest\test_loader.py" />
<Compile Include="test\test_unittest\test_program.py" />
<Compile Include="test\test_unittest\test_result.py" />
<Compile Include="test\test_unittest\test_runner.py" />
<Compile Include="test\test_unittest\test_setups.py" />
<Compile Include="test\test_unittest\test_skipping.py" />
<Compile Include="test\test_unittest\test_suite.py" />
<Compile Include="test\test_unittest\_test_warnings.py" />
<Compile Include="test\test_unittest\__init__.py" />
<Compile Include="test\test_unittest\__main__.py" />
<Compile Include="unittest\util.py" />
<Compile Include="unittest\__init__.py" />
<Compile Include="unittest\__main__.py" />
@ -1802,16 +1798,15 @@
<Folder Include="test\test_lib2to3\data\fixers" />
<Folder Include="test\test_lib2to3\data\fixers\myfixes" />
<Folder Include="test\test_peg_generator" />
<Folder Include="test\test_tkinter" />
<Folder Include="test\test_tools" />
<Folder Include="test\test_ttk" />
<Folder Include="test\test_unittest" />
<Folder Include="test\test_unittest\testmock" />
<Folder Include="test\test_warnings" />
<Folder Include="test\test_warnings\data" />
<Folder Include="test\tracedmodules" />
<Folder Include="tkinter" />
<Folder Include="tkinter\test" />
<Folder Include="tkinter\test\test_tkinter" />
<Folder Include="tkinter\test\test_ttk" />
<Folder Include="turtledemo" />
<Folder Include="unittest" />
<Folder Include="urllib" />

View File

@ -109,11 +109,6 @@ OMIT_MODULE_FILES = {
"_zoneinfo": ["zoneinfo/"],
}
# regression test sub directories
OMIT_SUBDIRS = (
"tkinter/test/",
)
def get_builddir(args: argparse.Namespace) -> pathlib.Path:
"""Get builddir path from pybuilddir.txt
"""
@ -136,9 +131,6 @@ def create_stdlib_zip(
*,
optimize: int = 0,
) -> None:
def filterfunc(name: str) -> bool:
return not name.startswith(args.omit_subdirs_absolute)
with zipfile.PyZipFile(
args.wasm_stdlib_zip, mode="w", compression=args.compression, optimize=optimize
) as pzf:
@ -152,7 +144,7 @@ def create_stdlib_zip(
continue
if entry.name.endswith(".py") or entry.is_dir():
# writepy() writes .pyc files (bytecode).
pzf.writepy(entry, filterfunc=filterfunc)
pzf.writepy(entry)
def detect_extension_modules(args: argparse.Namespace):
@ -234,9 +226,6 @@ def main():
omit_files.extend(modfiles)
args.omit_files_absolute = {args.srcdir_lib / name for name in omit_files}
args.omit_subdirs_absolute = tuple(
str(args.srcdir_lib / name) for name in OMIT_SUBDIRS
)
# Empty, unused directory for dynamic libs, but required for site initialization.
args.wasm_dynload.mkdir(parents=True, exist_ok=True)