Skip to content

Commit

Permalink
gh-54781: Move Lib/tkinter/test/test_ttk/ to Lib/test/test_ttk/ (#94070)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
vstinner authored Jun 22, 2022
1 parent 47e3562 commit c1fb12e
Show file tree
Hide file tree
Showing 29 changed files with 100 additions and 109 deletions.
20 changes: 0 additions & 20 deletions Lib/test/test_tk.py

This file was deleted.

File renamed without changes.
18 changes: 18 additions & 0 deletions Lib/test/test_tkinter/__init__.py
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 4 additions & 0 deletions Lib/test/test_tkinter/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import load_tests
import unittest

unittest.main()
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
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')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
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')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
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')

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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')

Expand Down
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
Original file line number Diff line number Diff line change
@@ -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')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
15 changes: 7 additions & 8 deletions Lib/test/test_ttk_guionly.py → Lib/test/test_ttk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
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')

# Skip test if tk cannot be initialized.
support.requires('gui')


import tkinter
from _tkinter import TclError
from tkinter import ttk
Expand All @@ -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)
4 changes: 4 additions & 0 deletions Lib/test/test_ttk/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import load_tests
import unittest

unittest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
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)

Expand Down
Empty file removed Lib/tkinter/test/__init__.py
Empty file.
Empty file.
Empty file.
6 changes: 3 additions & 3 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Rename test_tk to test_tkinter, and rename test_ttk_guionly to test_ttk.
Patch by Victor Stinner.
93 changes: 44 additions & 49 deletions PCbuild/lib.pyproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand All @@ -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" />
Expand All @@ -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" />
Expand Down Expand Up @@ -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" />
Expand Down Expand Up @@ -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" />
Expand Down Expand Up @@ -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" />
Expand Down
Loading

0 comments on commit c1fb12e

Please sign in to comment.