Skip to content

Commit c1fb12e

Browse files
authored
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.
1 parent 47e3562 commit c1fb12e

29 files changed

+100
-109
lines changed

Lib/test/test_tk.py

-20
This file was deleted.
File renamed without changes.

Lib/test/test_tkinter/__init__.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import os.path
2+
import unittest
3+
from test import support
4+
from test.support import import_helper
5+
6+
7+
if support.check_sanitizer(address=True, memory=True):
8+
raise unittest.SkipTest("Tests involving libX11 can SEGFAULT on ASAN/MSAN builds")
9+
10+
# Skip test if _tkinter wasn't built.
11+
import_helper.import_module('_tkinter')
12+
13+
# Skip test if tk cannot be initialized.
14+
support.requires('gui')
15+
16+
17+
def load_tests(*args):
18+
return support.load_package_tests(os.path.dirname(__file__), *args)

Lib/test/test_tkinter/__main__.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from . import load_tests
2+
import unittest
3+
4+
unittest.main()
File renamed without changes.

Lib/tkinter/test/test_tkinter/test_colorchooser.py Lib/test/test_tkinter/test_colorchooser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import unittest
22
import tkinter
33
from test.support import requires, swap_attr
4-
from tkinter.test.support import AbstractDefaultRootTest, AbstractTkTest
4+
from test.test_tkinter.support import AbstractDefaultRootTest, AbstractTkTest
55
from tkinter import colorchooser
66
from tkinter.colorchooser import askcolor
77
from tkinter.commondialog import Dialog

Lib/tkinter/test/test_tkinter/test_font.py Lib/test/test_tkinter/test_font.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import tkinter
33
from tkinter import font
44
from test.support import requires, gc_collect, ALWAYS_EQ
5-
from tkinter.test.support import AbstractTkTest, AbstractDefaultRootTest
5+
from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest
66

77
requires('gui')
88

Lib/tkinter/test/test_tkinter/test_geometry_managers.py Lib/test/test_tkinter/test_geometry_managers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from tkinter import TclError
55
from test.support import requires
66

7-
from tkinter.test.support import pixels_conv
8-
from tkinter.test.widget_tests import AbstractWidgetTest
7+
from test.test_tkinter.support import pixels_conv
8+
from test.test_tkinter.widget_tests import AbstractWidgetTest
99

1010
requires('gui')
1111

Lib/tkinter/test/test_tkinter/test_images.py Lib/test/test_tkinter/test_images.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import tkinter
33
from test import support
44
from test.support import os_helper
5-
from tkinter.test.support import AbstractTkTest, AbstractDefaultRootTest, requires_tcl
5+
from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest, requires_tcl
66

77
support.requires('gui')
88

Lib/tkinter/test/test_tkinter/test_messagebox.py Lib/test/test_tkinter/test_messagebox.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import unittest
22
import tkinter
33
from test.support import requires, swap_attr
4-
from tkinter.test.support import AbstractDefaultRootTest
4+
from test.test_tkinter.support import AbstractDefaultRootTest
55
from tkinter.commondialog import Dialog
66
from tkinter.messagebox import showinfo
77

Lib/tkinter/test/test_tkinter/test_misc.py Lib/test/test_tkinter/test_misc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import tkinter
44
import enum
55
from test import support
6-
from tkinter.test.support import AbstractTkTest, AbstractDefaultRootTest
6+
from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest
77

88
support.requires('gui')
99

Lib/tkinter/test/test_tkinter/test_simpledialog.py Lib/test/test_tkinter/test_simpledialog.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import unittest
22
import tkinter
33
from test.support import requires, swap_attr
4-
from tkinter.test.support import AbstractDefaultRootTest
4+
from test.test_tkinter.support import AbstractDefaultRootTest
55
from tkinter.simpledialog import Dialog, askinteger
66

77
requires('gui')

Lib/tkinter/test/test_tkinter/test_text.py Lib/test/test_tkinter/test_text.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import unittest
22
import tkinter
33
from test.support import requires
4-
from tkinter.test.support import AbstractTkTest
4+
from test.test_tkinter.support import AbstractTkTest
55

66
requires('gui')
77

Lib/tkinter/test/test_tkinter/test_variables.py Lib/test/test_tkinter/test_variables.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from tkinter import (Variable, StringVar, IntVar, DoubleVar, BooleanVar, Tcl,
77
TclError)
88
from test.support import ALWAYS_EQ
9-
from tkinter.test.support import AbstractDefaultRootTest
9+
from test.test_tkinter.support import AbstractDefaultRootTest
1010

1111

1212
class Var(Variable):

Lib/tkinter/test/test_tkinter/test_widgets.py Lib/test/test_tkinter/test_widgets.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import os
55
from test.support import requires
66

7-
from tkinter.test.support import (requires_tcl,
7+
from test.test_tkinter.support import (requires_tcl,
88
get_tk_patchlevel, widget_eq,
99
AbstractDefaultRootTest)
10-
from tkinter.test.widget_tests import (
10+
from test.test_tkinter.widget_tests import (
1111
add_standard_options,
1212
AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests,
1313
setUpModule)

Lib/tkinter/test/widget_tests.py Lib/test/test_tkinter/widget_tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Common tests for test_tkinter/test_widgets.py and test_ttk/test_widgets.py
22

33
import tkinter
4-
from tkinter.test.support import (AbstractTkTest, tcl_version,
4+
from test.test_tkinter.support import (AbstractTkTest, tcl_version,
55
pixels_conv, tcl_obj_eq)
66
import test.support
77

Lib/test/test_ttk_guionly.py Lib/test/test_ttk/__init__.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1+
import os.path
12
import unittest
23
from test import support
34
from test.support import import_helper
4-
from test.support import check_sanitizer
55

6-
if check_sanitizer(address=True, memory=True):
7-
raise unittest.SkipTest("Tests involvin libX11 can SEGFAULT on ASAN/MSAN builds")
6+
7+
if support.check_sanitizer(address=True, memory=True):
8+
raise unittest.SkipTest("Tests involving libX11 can SEGFAULT on ASAN/MSAN builds")
89

910
# Skip this test if _tkinter wasn't built.
1011
import_helper.import_module('_tkinter')
1112

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

16+
1517
import tkinter
1618
from _tkinter import TclError
1719
from tkinter import ttk
@@ -32,9 +34,6 @@ def setUpModule():
3234
root.destroy()
3335
del root
3436

35-
def load_tests(loader, tests, pattern):
36-
return loader.discover('tkinter.test.test_ttk')
37-
3837

39-
if __name__ == '__main__':
40-
unittest.main()
38+
def load_tests(*args):
39+
return support.load_package_tests(os.path.dirname(__file__), *args)

Lib/test/test_ttk/__main__.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from . import load_tests
2+
import unittest
3+
4+
unittest.main()

Lib/tkinter/test/test_ttk/test_extensions.py Lib/test/test_ttk/test_extensions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import tkinter
44
from tkinter import ttk
55
from test.support import requires, gc_collect
6-
from tkinter.test.support import AbstractTkTest, AbstractDefaultRootTest
6+
from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest
77

88
requires('gui')
99

Lib/tkinter/test/test_ttk/test_style.py Lib/test/test_ttk/test_style.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from tkinter import ttk
55
from test import support
66
from test.support import requires
7-
from tkinter.test.support import AbstractTkTest, get_tk_patchlevel
7+
from test.test_tkinter.support import AbstractTkTest, get_tk_patchlevel
88

99
requires('gui')
1010

Lib/tkinter/test/test_ttk/test_widgets.py Lib/test/test_ttk/test_widgets.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
import sys
66

77
from test.test_ttk_textonly import MockTclObj
8-
from tkinter.test.support import (AbstractTkTest, tcl_version, get_tk_patchlevel,
8+
from test.test_tkinter.support import (AbstractTkTest, tcl_version, get_tk_patchlevel,
99
simulate_mouse_click, AbstractDefaultRootTest)
10-
from tkinter.test.widget_tests import (add_standard_options,
10+
from test.test_tkinter.widget_tests import (add_standard_options,
1111
AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests,
1212
setUpModule)
1313

Lib/tkinter/test/__init__.py

Whitespace-only changes.

Lib/tkinter/test/test_tkinter/__init__.py

Whitespace-only changes.

Lib/tkinter/test/test_ttk/__init__.py

Whitespace-only changes.

Makefile.pre.in

+3-3
Original file line numberDiff line numberDiff line change
@@ -1987,15 +1987,15 @@ TESTSUBDIRS= distutils/tests \
19871987
test/test_lib2to3/data/fixers \
19881988
test/test_lib2to3/data/fixers/myfixes \
19891989
test/test_peg_generator \
1990+
test/test_tkinter \
19901991
test/test_tools \
1992+
test/test_ttk \
19911993
test/test_warnings test/test_warnings/data \
19921994
test/test_zoneinfo test/test_zoneinfo/data \
19931995
test/test_unittest test/test_unittest/testmock \
19941996
test/tracedmodules \
19951997
test/xmltestdata test/xmltestdata/c14n-20 \
1996-
test/ziptestdata \
1997-
tkinter/test tkinter/test/test_tkinter \
1998-
tkinter/test/test_ttk
1998+
test/ziptestdata
19991999

20002000
TEST_MODULES=@TEST_MODULES@
20012001
libinstall: all $(srcdir)/Modules/xxmodule.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Rename test_tk to test_tkinter, and rename test_ttk_guionly to test_ttk.
2+
Patch by Victor Stinner.

PCbuild/lib.pyproj

+44-49
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,17 @@
13231323
<Compile Include="test\test_timeit.py" />
13241324
<Compile Include="test\test_timeout.py" />
13251325
<Compile Include="test\test_tix.py" />
1326-
<Compile Include="test\test_tk.py" />
1326+
<Compile Include="test\test_tkinter\__init__.py" />
1327+
<Compile Include="test\test_tkinter\support.py" />
1328+
<Compile Include="test\test_tkinter\test_font.py" />
1329+
<Compile Include="test\test_tkinter\test_geometry_managers.py" />
1330+
<Compile Include="test\test_tkinter\test_images.py" />
1331+
<Compile Include="test\test_tkinter\test_loadtk.py" />
1332+
<Compile Include="test\test_tkinter\test_misc.py" />
1333+
<Compile Include="test\test_tkinter\test_text.py" />
1334+
<Compile Include="test\test_tkinter\test_variables.py" />
1335+
<Compile Include="test\test_tkinter\test_widgets.py" />
1336+
<Compile Include="test\test_tkinter\widget_tests.py" />
13271337
<Compile Include="test\test_tokenize.py" />
13281338
<Compile Include="test\test_tools\test_fixcid.py" />
13291339
<Compile Include="test\test_tools\test_gprof2html.py" />
@@ -1339,8 +1349,11 @@
13391349
<Compile Include="test\test_trace.py" />
13401350
<Compile Include="test\test_traceback.py" />
13411351
<Compile Include="test\test_tracemalloc.py" />
1342-
<Compile Include="test\test_ttk_guionly.py" />
13431352
<Compile Include="test\test_ttk_textonly.py" />
1353+
<Compile Include="test\test_ttk\__init__.py" />
1354+
<Compile Include="test\test_ttk\test_extensions.py" />
1355+
<Compile Include="test\test_ttk\test_style.py" />
1356+
<Compile Include="test\test_ttk\test_widgets.py" />
13441357
<Compile Include="test\test_tuple.py" />
13451358
<Compile Include="test\test_turtle.py" />
13461359
<Compile Include="test\test_typechecks.py" />
@@ -1353,7 +1366,33 @@
13531366
<Compile Include="test\test_unicode_file.py" />
13541367
<Compile Include="test\test_unicode_file_functions.py" />
13551368
<Compile Include="test\test_unicode_identifiers.py" />
1356-
<Compile Include="test\test_unittest.py" />
1369+
<Compile Include="test\test_unittest\dummy.py" />
1370+
<Compile Include="test\test_unittest\support.py" />
1371+
<Compile Include="test\test_unittest\testmock\support.py" />
1372+
<Compile Include="test\test_unittest\testmock\testcallable.py" />
1373+
<Compile Include="test\test_unittest\testmock\testhelpers.py" />
1374+
<Compile Include="test\test_unittest\testmock\testmagicmethods.py" />
1375+
<Compile Include="test\test_unittest\testmock\testmock.py" />
1376+
<Compile Include="test\test_unittest\testmock\testpatch.py" />
1377+
<Compile Include="test\test_unittest\testmock\testsentinel.py" />
1378+
<Compile Include="test\test_unittest\testmock\testwith.py" />
1379+
<Compile Include="test\test_unittest\testmock\__init__.py" />
1380+
<Compile Include="test\test_unittest\testmock\__main__.py" />
1381+
<Compile Include="test\test_unittest\test_assertions.py" />
1382+
<Compile Include="test\test_unittest\test_break.py" />
1383+
<Compile Include="test\test_unittest\test_case.py" />
1384+
<Compile Include="test\test_unittest\test_discovery.py" />
1385+
<Compile Include="test\test_unittest\test_functiontestcase.py" />
1386+
<Compile Include="test\test_unittest\test_loader.py" />
1387+
<Compile Include="test\test_unittest\test_program.py" />
1388+
<Compile Include="test\test_unittest\test_result.py" />
1389+
<Compile Include="test\test_unittest\test_runner.py" />
1390+
<Compile Include="test\test_unittest\test_setups.py" />
1391+
<Compile Include="test\test_unittest\test_skipping.py" />
1392+
<Compile Include="test\test_unittest\test_suite.py" />
1393+
<Compile Include="test\test_unittest\_test_warnings.py" />
1394+
<Compile Include="test\test_unittest\__init__.py" />
1395+
<Compile Include="test\test_unittest\__main__.py" />
13571396
<Compile Include="test\test_univnewlines.py" />
13581397
<Compile Include="test\test_unpack.py" />
13591398
<Compile Include="test\test_unpack_ex.py" />
@@ -1432,22 +1471,6 @@
14321471
<Compile Include="tkinter\messagebox.py" />
14331472
<Compile Include="tkinter\scrolledtext.py" />
14341473
<Compile Include="tkinter\simpledialog.py" />
1435-
<Compile Include="tkinter\test\support.py" />
1436-
<Compile Include="tkinter\test\test_tkinter\test_font.py" />
1437-
<Compile Include="tkinter\test\test_tkinter\test_geometry_managers.py" />
1438-
<Compile Include="tkinter\test\test_tkinter\test_images.py" />
1439-
<Compile Include="tkinter\test\test_tkinter\test_loadtk.py" />
1440-
<Compile Include="tkinter\test\test_tkinter\test_misc.py" />
1441-
<Compile Include="tkinter\test\test_tkinter\test_text.py" />
1442-
<Compile Include="tkinter\test\test_tkinter\test_variables.py" />
1443-
<Compile Include="tkinter\test\test_tkinter\test_widgets.py" />
1444-
<Compile Include="tkinter\test\test_tkinter\__init__.py" />
1445-
<Compile Include="tkinter\test\test_ttk\test_extensions.py" />
1446-
<Compile Include="tkinter\test\test_ttk\test_style.py" />
1447-
<Compile Include="tkinter\test\test_ttk\test_widgets.py" />
1448-
<Compile Include="tkinter\test\test_ttk\__init__.py" />
1449-
<Compile Include="tkinter\test\widget_tests.py" />
1450-
<Compile Include="tkinter\test\__init__.py" />
14511474
<Compile Include="tkinter\tix.py" />
14521475
<Compile Include="tkinter\ttk.py" />
14531476
<Compile Include="tkinter\__init__.py" />
@@ -1490,33 +1513,6 @@
14901513
<Compile Include="unittest\runner.py" />
14911514
<Compile Include="unittest\signals.py" />
14921515
<Compile Include="unittest\suite.py" />
1493-
<Compile Include="test\test_unittest\dummy.py" />
1494-
<Compile Include="test\test_unittest\support.py" />
1495-
<Compile Include="test\test_unittest\testmock\support.py" />
1496-
<Compile Include="test\test_unittest\testmock\testcallable.py" />
1497-
<Compile Include="test\test_unittest\testmock\testhelpers.py" />
1498-
<Compile Include="test\test_unittest\testmock\testmagicmethods.py" />
1499-
<Compile Include="test\test_unittest\testmock\testmock.py" />
1500-
<Compile Include="test\test_unittest\testmock\testpatch.py" />
1501-
<Compile Include="test\test_unittest\testmock\testsentinel.py" />
1502-
<Compile Include="test\test_unittest\testmock\testwith.py" />
1503-
<Compile Include="test\test_unittest\testmock\__init__.py" />
1504-
<Compile Include="test\test_unittest\testmock\__main__.py" />
1505-
<Compile Include="test\test_unittest\test_assertions.py" />
1506-
<Compile Include="test\test_unittest\test_break.py" />
1507-
<Compile Include="test\test_unittest\test_case.py" />
1508-
<Compile Include="test\test_unittest\test_discovery.py" />
1509-
<Compile Include="test\test_unittest\test_functiontestcase.py" />
1510-
<Compile Include="test\test_unittest\test_loader.py" />
1511-
<Compile Include="test\test_unittest\test_program.py" />
1512-
<Compile Include="test\test_unittest\test_result.py" />
1513-
<Compile Include="test\test_unittest\test_runner.py" />
1514-
<Compile Include="test\test_unittest\test_setups.py" />
1515-
<Compile Include="test\test_unittest\test_skipping.py" />
1516-
<Compile Include="test\test_unittest\test_suite.py" />
1517-
<Compile Include="test\test_unittest\_test_warnings.py" />
1518-
<Compile Include="test\test_unittest\__init__.py" />
1519-
<Compile Include="test\test_unittest\__main__.py" />
15201516
<Compile Include="unittest\util.py" />
15211517
<Compile Include="unittest\__init__.py" />
15221518
<Compile Include="unittest\__main__.py" />
@@ -1802,16 +1798,15 @@
18021798
<Folder Include="test\test_lib2to3\data\fixers" />
18031799
<Folder Include="test\test_lib2to3\data\fixers\myfixes" />
18041800
<Folder Include="test\test_peg_generator" />
1801+
<Folder Include="test\test_tkinter" />
18051802
<Folder Include="test\test_tools" />
1803+
<Folder Include="test\test_ttk" />
18061804
<Folder Include="test\test_unittest" />
18071805
<Folder Include="test\test_unittest\testmock" />
18081806
<Folder Include="test\test_warnings" />
18091807
<Folder Include="test\test_warnings\data" />
18101808
<Folder Include="test\tracedmodules" />
18111809
<Folder Include="tkinter" />
1812-
<Folder Include="tkinter\test" />
1813-
<Folder Include="tkinter\test\test_tkinter" />
1814-
<Folder Include="tkinter\test\test_ttk" />
18151810
<Folder Include="turtledemo" />
18161811
<Folder Include="unittest" />
18171812
<Folder Include="urllib" />

0 commit comments

Comments
 (0)