Skip to content

Commit 080a596

Browse files
authored
GH-71383: IDLE - Document testing subsets of modules (#104463)
1 parent 7d2deaf commit 080a596

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

Lib/idlelib/idle_test/README.txt

+11-8
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,17 @@ python -m unittest -v idlelib.idle_test
146146
python -m test -v -ugui test_idle
147147
python -m test.test_idle
148148

149-
The idle tests are 'discovered' by
150-
idlelib.idle_test.__init__.load_tests, which is also imported into
151-
test.test_idle. Normally, neither file should be changed when working on
152-
individual test modules. The third command runs unittest indirectly
153-
through regrtest. The same happens when the entire test suite is run
154-
with 'python -m test'. So that command must work for buildbots to stay
155-
green. Idle tests must not disturb the environment in a way that makes
156-
other tests fail (issue 18081).
149+
IDLE tests are 'discovered' by idlelib.idle_test.__init__.load_tests
150+
when this is imported into test.test_idle. Normally, neither file
151+
should be changed when working on individual test modules. The third
152+
command runs unittest indirectly through regrtest. The same happens when
153+
the entire test suite is run with 'python -m test'. So that command must
154+
work for buildbots to stay green. IDLE tests must not disturb the
155+
environment in a way that makes other tests fail (GH-62281).
156+
157+
To test subsets of modules, see idlelib.idle_test.__init__. This
158+
can be used to find refleaks or possible sources of "Theme changed"
159+
tcl messages (GH-71383).
157160

158161
To run an individual Testcase or test method, extend the dotted name
159162
given to unittest on the command line or use the test -m option. The

Lib/idlelib/idle_test/__init__.py

+17-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
1-
'''idlelib.idle_test is a private implementation of test.test_idle,
2-
which tests the IDLE application as part of the stdlib test suite.
3-
Run IDLE tests alone with "python -m test.test_idle".
4-
Starting with Python 3.6, IDLE requires tcl/tk 8.5 or later.
1+
"""idlelib.idle_test implements test.test_idle, which tests the IDLE
2+
application as part of the stdlib test suite.
3+
Run IDLE tests alone with "python -m test.test_idle (-v)".
54
65
This package and its contained modules are subject to change and
76
any direct use is at your own risk.
8-
'''
7+
"""
98
from os.path import dirname
109

10+
# test_idle imports load_tests for test discovery (default all).
11+
# To run subsets of idlelib module tests, insert '[<chars>]' after '_'.
12+
# Example: insert '[ac]' for modules beginning with 'a' or 'c'.
13+
# Additional .discover/.addTest pairs with separate inserts work.
14+
# Example: pairs with 'c' and 'g' test c* files and grep.
15+
1116
def load_tests(loader, standard_tests, pattern):
1217
this_dir = dirname(__file__)
1318
top_dir = dirname(dirname(this_dir))
14-
package_tests = loader.discover(start_dir=this_dir, pattern='test*.py',
19+
module_tests = loader.discover(start_dir=this_dir,
20+
pattern='test_*.py', # Insert here.
1521
top_level_dir=top_dir)
16-
standard_tests.addTests(package_tests)
22+
standard_tests.addTests(module_tests)
23+
## module_tests = loader.discover(start_dir=this_dir,
24+
## pattern='test_*.py', # Insert here.
25+
## top_level_dir=top_dir)
26+
## standard_tests.addTests(module_tests)
1727
return standard_tests

Lib/test/test_idle.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@
55
if check_sanitizer(address=True, memory=True):
66
raise unittest.SkipTest("Tests involving libX11 can SEGFAULT on ASAN/MSAN builds")
77

8-
# Skip test_idle if _tkinter wasn't built, if tkinter is missing,
9-
# if tcl/tk is not the 8.5+ needed for ttk widgets,
10-
# or if idlelib is missing (not installed).
8+
# Skip test_idle if _tkinter, tkinter, or idlelib are missing.
119
tk = import_module('tkinter') # Also imports _tkinter.
12-
if tk.TkVersion < 8.5:
13-
raise unittest.SkipTest("IDLE requires tk 8.5 or later.")
1410
idlelib = import_module('idlelib')
1511

1612
# Before importing and executing more of idlelib,

0 commit comments

Comments
 (0)