From c1fb12e5afa09aca3134a9bc0116c31dbcccc5e9 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 22 Jun 2022 22:23:37 +0200 Subject: [PATCH] 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. --- Lib/test/test_tk.py | 20 ---- .../test => test/test_tkinter}/README | 0 Lib/test/test_tkinter/__init__.py | 18 ++++ Lib/test/test_tkinter/__main__.py | 4 + .../test => test/test_tkinter}/support.py | 0 .../test/test_tkinter/test_colorchooser.py | 2 +- .../test/test_tkinter/test_font.py | 2 +- .../test_tkinter/test_geometry_managers.py | 4 +- .../test/test_tkinter/test_images.py | 2 +- .../test/test_tkinter/test_loadtk.py | 0 .../test/test_tkinter/test_messagebox.py | 2 +- .../test/test_tkinter/test_misc.py | 2 +- .../test/test_tkinter/test_simpledialog.py | 2 +- .../test/test_tkinter/test_text.py | 2 +- .../test/test_tkinter/test_variables.py | 2 +- .../test/test_tkinter/test_widgets.py | 4 +- .../test_tkinter}/widget_tests.py | 2 +- .../__init__.py} | 15 ++- Lib/test/test_ttk/__main__.py | 4 + .../test/test_ttk/test_extensions.py | 2 +- Lib/{tkinter => }/test/test_ttk/test_style.py | 2 +- .../test/test_ttk/test_widgets.py | 4 +- Lib/tkinter/test/__init__.py | 0 Lib/tkinter/test/test_tkinter/__init__.py | 0 Lib/tkinter/test/test_ttk/__init__.py | 0 Makefile.pre.in | 6 +- ...2-06-21-17-37-46.gh-issue-54781.BjVAVg.rst | 2 + PCbuild/lib.pyproj | 93 +++++++++---------- Tools/wasm/wasm_assets.py | 13 +-- 29 files changed, 100 insertions(+), 109 deletions(-) delete mode 100644 Lib/test/test_tk.py rename Lib/{tkinter/test => test/test_tkinter}/README (100%) create mode 100644 Lib/test/test_tkinter/__init__.py create mode 100644 Lib/test/test_tkinter/__main__.py rename Lib/{tkinter/test => test/test_tkinter}/support.py (100%) rename Lib/{tkinter => }/test/test_tkinter/test_colorchooser.py (96%) rename Lib/{tkinter => }/test/test_tkinter/test_font.py (98%) rename Lib/{tkinter => }/test/test_tkinter/test_geometry_managers.py (99%) rename Lib/{tkinter => }/test/test_tkinter/test_images.py (99%) rename Lib/{tkinter => }/test/test_tkinter/test_loadtk.py (100%) rename Lib/{tkinter => }/test/test_tkinter/test_messagebox.py (94%) rename Lib/{tkinter => }/test/test_tkinter/test_misc.py (99%) rename Lib/{tkinter => }/test/test_tkinter/test_simpledialog.py (93%) rename Lib/{tkinter => }/test/test_tkinter/test_text.py (96%) rename Lib/{tkinter => }/test/test_tkinter/test_variables.py (99%) rename Lib/{tkinter => }/test/test_tkinter/test_widgets.py (99%) rename Lib/{tkinter/test => test/test_tkinter}/widget_tests.py (99%) rename Lib/test/{test_ttk_guionly.py => test_ttk/__init__.py} (68%) create mode 100644 Lib/test/test_ttk/__main__.py rename Lib/{tkinter => }/test/test_ttk/test_extensions.py (99%) rename Lib/{tkinter => }/test/test_ttk/test_style.py (98%) rename Lib/{tkinter => }/test/test_ttk/test_widgets.py (99%) delete mode 100644 Lib/tkinter/test/__init__.py delete mode 100644 Lib/tkinter/test/test_tkinter/__init__.py delete mode 100644 Lib/tkinter/test/test_ttk/__init__.py create mode 100644 Misc/NEWS.d/next/Tests/2022-06-21-17-37-46.gh-issue-54781.BjVAVg.rst diff --git a/Lib/test/test_tk.py b/Lib/test/test_tk.py deleted file mode 100644 index 8f90cbaba9f..00000000000 --- a/Lib/test/test_tk.py +++ /dev/null @@ -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() diff --git a/Lib/tkinter/test/README b/Lib/test/test_tkinter/README similarity index 100% rename from Lib/tkinter/test/README rename to Lib/test/test_tkinter/README diff --git a/Lib/test/test_tkinter/__init__.py b/Lib/test/test_tkinter/__init__.py new file mode 100644 index 00000000000..edcb44951bd --- /dev/null +++ b/Lib/test/test_tkinter/__init__.py @@ -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) diff --git a/Lib/test/test_tkinter/__main__.py b/Lib/test/test_tkinter/__main__.py new file mode 100644 index 00000000000..40a23a297ec --- /dev/null +++ b/Lib/test/test_tkinter/__main__.py @@ -0,0 +1,4 @@ +from . import load_tests +import unittest + +unittest.main() diff --git a/Lib/tkinter/test/support.py b/Lib/test/test_tkinter/support.py similarity index 100% rename from Lib/tkinter/test/support.py rename to Lib/test/test_tkinter/support.py diff --git a/Lib/tkinter/test/test_tkinter/test_colorchooser.py b/Lib/test/test_tkinter/test_colorchooser.py similarity index 96% rename from Lib/tkinter/test/test_tkinter/test_colorchooser.py rename to Lib/test/test_tkinter/test_colorchooser.py index 488162ff0dd..9bba21392d8 100644 --- a/Lib/tkinter/test/test_tkinter/test_colorchooser.py +++ b/Lib/test/test_tkinter/test_colorchooser.py @@ -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 diff --git a/Lib/tkinter/test/test_tkinter/test_font.py b/Lib/test/test_tkinter/test_font.py similarity index 98% rename from Lib/tkinter/test/test_tkinter/test_font.py rename to Lib/test/test_tkinter/test_font.py index 058c53a9023..563707ddd2f 100644 --- a/Lib/tkinter/test/test_tkinter/test_font.py +++ b/Lib/test/test_tkinter/test_font.py @@ -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') diff --git a/Lib/tkinter/test/test_tkinter/test_geometry_managers.py b/Lib/test/test_tkinter/test_geometry_managers.py similarity index 99% rename from Lib/tkinter/test/test_tkinter/test_geometry_managers.py rename to Lib/test/test_tkinter/test_geometry_managers.py index c89bc8dbf85..3663048a145 100644 --- a/Lib/tkinter/test/test_tkinter/test_geometry_managers.py +++ b/Lib/test/test_tkinter/test_geometry_managers.py @@ -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') diff --git a/Lib/tkinter/test/test_tkinter/test_images.py b/Lib/test/test_tkinter/test_images.py similarity index 99% rename from Lib/tkinter/test/test_tkinter/test_images.py rename to Lib/test/test_tkinter/test_images.py index cc69ccac62d..b6f8b79ae68 100644 --- a/Lib/tkinter/test/test_tkinter/test_images.py +++ b/Lib/test/test_tkinter/test_images.py @@ -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') diff --git a/Lib/tkinter/test/test_tkinter/test_loadtk.py b/Lib/test/test_tkinter/test_loadtk.py similarity index 100% rename from Lib/tkinter/test/test_tkinter/test_loadtk.py rename to Lib/test/test_tkinter/test_loadtk.py diff --git a/Lib/tkinter/test/test_tkinter/test_messagebox.py b/Lib/test/test_tkinter/test_messagebox.py similarity index 94% rename from Lib/tkinter/test/test_tkinter/test_messagebox.py rename to Lib/test/test_tkinter/test_messagebox.py index d38541a5a45..f41bdc98286 100644 --- a/Lib/tkinter/test/test_tkinter/test_messagebox.py +++ b/Lib/test/test_tkinter/test_messagebox.py @@ -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 diff --git a/Lib/tkinter/test/test_tkinter/test_misc.py b/Lib/test/test_tkinter/test_misc.py similarity index 99% rename from Lib/tkinter/test/test_tkinter/test_misc.py rename to Lib/test/test_tkinter/test_misc.py index 620b6ed638c..d1aca58d15f 100644 --- a/Lib/tkinter/test/test_tkinter/test_misc.py +++ b/Lib/test/test_tkinter/test_misc.py @@ -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') diff --git a/Lib/tkinter/test/test_tkinter/test_simpledialog.py b/Lib/test/test_tkinter/test_simpledialog.py similarity index 93% rename from Lib/tkinter/test/test_tkinter/test_simpledialog.py rename to Lib/test/test_tkinter/test_simpledialog.py index 18cd2712b0c..502f7f7098a 100644 --- a/Lib/tkinter/test/test_tkinter/test_simpledialog.py +++ b/Lib/test/test_tkinter/test_simpledialog.py @@ -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') diff --git a/Lib/tkinter/test/test_tkinter/test_text.py b/Lib/test/test_tkinter/test_text.py similarity index 96% rename from Lib/tkinter/test/test_tkinter/test_text.py rename to Lib/test/test_tkinter/test_text.py index 482f150df55..d1583f0b20a 100644 --- a/Lib/tkinter/test/test_tkinter/test_text.py +++ b/Lib/test/test_tkinter/test_text.py @@ -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') diff --git a/Lib/tkinter/test/test_tkinter/test_variables.py b/Lib/test/test_tkinter/test_variables.py similarity index 99% rename from Lib/tkinter/test/test_tkinter/test_variables.py rename to Lib/test/test_tkinter/test_variables.py index 427e1684543..c1d232e2feb 100644 --- a/Lib/tkinter/test/test_tkinter/test_variables.py +++ b/Lib/test/test_tkinter/test_variables.py @@ -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): diff --git a/Lib/tkinter/test/test_tkinter/test_widgets.py b/Lib/test/test_tkinter/test_widgets.py similarity index 99% rename from Lib/tkinter/test/test_tkinter/test_widgets.py rename to Lib/test/test_tkinter/test_widgets.py index fe8ecfeb326..1cddbe17ba5 100644 --- a/Lib/tkinter/test/test_tkinter/test_widgets.py +++ b/Lib/test/test_tkinter/test_widgets.py @@ -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) diff --git a/Lib/tkinter/test/widget_tests.py b/Lib/test/test_tkinter/widget_tests.py similarity index 99% rename from Lib/tkinter/test/widget_tests.py rename to Lib/test/test_tkinter/widget_tests.py index 8418154d64a..85b0511aba3 100644 --- a/Lib/tkinter/test/widget_tests.py +++ b/Lib/test/test_tkinter/widget_tests.py @@ -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 diff --git a/Lib/test/test_ttk_guionly.py b/Lib/test/test_ttk/__init__.py similarity index 68% rename from Lib/test/test_ttk_guionly.py rename to Lib/test/test_ttk/__init__.py index c4919045d75..7ee7ffbd6d7 100644 --- a/Lib/test/test_ttk_guionly.py +++ b/Lib/test/test_ttk/__init__.py @@ -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) diff --git a/Lib/test/test_ttk/__main__.py b/Lib/test/test_ttk/__main__.py new file mode 100644 index 00000000000..40a23a297ec --- /dev/null +++ b/Lib/test/test_ttk/__main__.py @@ -0,0 +1,4 @@ +from . import load_tests +import unittest + +unittest.main() diff --git a/Lib/tkinter/test/test_ttk/test_extensions.py b/Lib/test/test_ttk/test_extensions.py similarity index 99% rename from Lib/tkinter/test/test_ttk/test_extensions.py rename to Lib/test/test_ttk/test_extensions.py index 1220c4831c5..6135c49701f 100644 --- a/Lib/tkinter/test/test_ttk/test_extensions.py +++ b/Lib/test/test_ttk/test_extensions.py @@ -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') diff --git a/Lib/tkinter/test/test_ttk/test_style.py b/Lib/test/test_ttk/test_style.py similarity index 98% rename from Lib/tkinter/test/test_ttk/test_style.py rename to Lib/test/test_ttk/test_style.py index 54ad3437168..0ec95cf6b5f 100644 --- a/Lib/tkinter/test/test_ttk/test_style.py +++ b/Lib/test/test_ttk/test_style.py @@ -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') diff --git a/Lib/tkinter/test/test_ttk/test_widgets.py b/Lib/test/test_ttk/test_widgets.py similarity index 99% rename from Lib/tkinter/test/test_ttk/test_widgets.py rename to Lib/test/test_ttk/test_widgets.py index c14c321ca26..eb0cc93ce27 100644 --- a/Lib/tkinter/test/test_ttk/test_widgets.py +++ b/Lib/test/test_ttk/test_widgets.py @@ -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) diff --git a/Lib/tkinter/test/__init__.py b/Lib/tkinter/test/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/Lib/tkinter/test/test_tkinter/__init__.py b/Lib/tkinter/test/test_tkinter/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/Lib/tkinter/test/test_ttk/__init__.py b/Lib/tkinter/test/test_ttk/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/Makefile.pre.in b/Makefile.pre.in index 6448785c280..5d0ae6bca87 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -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 diff --git a/Misc/NEWS.d/next/Tests/2022-06-21-17-37-46.gh-issue-54781.BjVAVg.rst b/Misc/NEWS.d/next/Tests/2022-06-21-17-37-46.gh-issue-54781.BjVAVg.rst new file mode 100644 index 00000000000..f7ae7b976af --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2022-06-21-17-37-46.gh-issue-54781.BjVAVg.rst @@ -0,0 +1,2 @@ +Rename test_tk to test_tkinter, and rename test_ttk_guionly to test_ttk. +Patch by Victor Stinner. diff --git a/PCbuild/lib.pyproj b/PCbuild/lib.pyproj index 2355eb5486f..0556efe1a77 100644 --- a/PCbuild/lib.pyproj +++ b/PCbuild/lib.pyproj @@ -1323,7 +1323,17 @@ - + + + + + + + + + + + @@ -1339,8 +1349,11 @@ - + + + + @@ -1353,7 +1366,33 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1432,22 +1471,6 @@ - - - - - - - - - - - - - - - - @@ -1490,33 +1513,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1802,16 +1798,15 @@ + + - - - diff --git a/Tools/wasm/wasm_assets.py b/Tools/wasm/wasm_assets.py index 67afde60f09..a59db9db7cd 100755 --- a/Tools/wasm/wasm_assets.py +++ b/Tools/wasm/wasm_assets.py @@ -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)