Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e44f194

Browse files
authored
pythongh-66819: More IDLE htest updates (python#112574)
Revise htest.py docstring and move 2 specs to alphabetical position.
1 parent 5b06299 commit e44f194

File tree

1 file changed

+52
-55
lines changed

1 file changed

+52
-55
lines changed

Lib/idlelib/idle_test/htest.py

Lines changed: 52 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,35 @@
1-
'''Run human tests of Idle's window, dialog, and popup widgets.
2-
3-
run(*tests)
4-
Create a master Tk window. Within that, run each callable in tests
5-
after finding the matching test spec in this file. If tests is empty,
6-
run an htest for each spec dict in this file after finding the matching
7-
callable in the module named in the spec. Close the window to skip or
8-
end the test.
9-
10-
In a tested module, let X be a global name bound to a callable (class
11-
or function) whose .__name__ attribute is also X (the usual situation).
12-
The first parameter of X must be 'parent'. When called, the parent
13-
argument will be the root window. X must create a child Toplevel
14-
window (or subclass thereof). The Toplevel may be a test widget or
15-
dialog, in which case the callable is the corresponding class. Or the
16-
Toplevel may contain the widget to be tested or set up a context in
17-
which a test widget is invoked. In this latter case, the callable is a
18-
wrapper function that sets up the Toplevel and other objects. Wrapper
19-
function names, such as _editor_window', should start with '_'.
1+
"""Run human tests of Idle's window, dialog, and popup widgets.
2+
3+
run(*tests) Create a master Tk() htest window. Within that, run each
4+
callable in tests after finding the matching test spec in this file. If
5+
tests is empty, run an htest for each spec dict in this file after
6+
finding the matching callable in the module named in the spec. Close
7+
the master window to end testing.
8+
9+
In a tested module, let X be a global name bound to a callable (class or
10+
function) whose .__name__ attribute is also X (the usual situation). The
11+
first parameter of X must be 'parent'. When called, the parent argument
12+
will be the root window. X must create a child Toplevel(parent) window
13+
(or subclass thereof). The Toplevel may be a test widget or dialog, in
14+
which case the callable is the corresponding class. Or the Toplevel may
15+
contain the widget to be tested or set up a context in which a test
16+
widget is invoked. In this latter case, the callable is a wrapper
17+
function that sets up the Toplevel and other objects. Wrapper function
18+
names, such as _editor_window', should start with '_' and be lowercase.
2019
2120
2221
End the module with
2322
2423
if __name__ == '__main__':
25-
<unittest, if there is one>
24+
<run unittest.main with 'exit=False'>
2625
from idlelib.idle_test.htest import run
27-
run(X)
26+
run(callable) # There could be multiple comma-separated callables.
2827
29-
To have wrapper functions and test invocation code ignored by coveragepy
30-
reports, put '# htest #' on the def statement header line.
31-
32-
def _wrapper(parent): # htest #
33-
34-
Also make sure that the 'if __name__' line matches the above. Then have
35-
make sure that .coveragerc includes the following.
28+
To have wrapper functions ignored by coverage reports, tag the def
29+
header like so: "def _wrapper(parent): # htest #". Use the same tag
30+
for htest lines in widget code. Make sure that the 'if __name__' line
31+
matches the above. Then have make sure that .coveragerc includes the
32+
following:
3633
3734
[report]
3835
exclude_lines =
@@ -46,24 +43,24 @@ def _wrapper(parent): # htest #
4643
following template, with X.__name__ prepended to '_spec'.
4744
When all tests are run, the prefix is use to get X.
4845
49-
_spec = {
46+
callable_spec = {
5047
'file': '',
5148
'kwds': {'title': ''},
5249
'msg': ""
5350
}
5451
5552
file (no .py): run() imports file.py.
5653
kwds: augmented with {'parent':root} and passed to X as **kwds.
57-
title: an example kwd; some widgets need this, delete if not.
54+
title: an example kwd; some widgets need this, delete line if not.
5855
msg: master window hints about testing the widget.
5956
6057
61-
Modules and classes not being tested at the moment:
62-
pyshell.PyShellEditorWindow
63-
debugger.Debugger
64-
autocomplete_w.AutoCompleteWindow
65-
outwin.OutputWindow (indirectly being tested with grep test)
66-
'''
58+
TODO test these modules and classes:
59+
autocomplete_w.AutoCompleteWindow
60+
debugger.Debugger
61+
outwin.OutputWindow (indirectly being tested with grep test)
62+
pyshell.PyShellEditorWindow
63+
"""
6764

6865
import idlelib.pyshell # Set Windows DPI awareness before Tk().
6966
from importlib import import_module
@@ -91,15 +88,6 @@ def _wrapper(parent): # htest #
9188
"Force-open-calltip does not work here.\n"
9289
}
9390

94-
_module_browser_spec = {
95-
'file': 'browser',
96-
'kwds': {},
97-
'msg': "Inspect names of module, class(with superclass if "
98-
"applicable), methods and functions.\nToggle nested items.\n"
99-
"Double clicking on items prints a traceback for an exception "
100-
"that is ignored."
101-
}
102-
10391
_color_delegator_spec = {
10492
'file': 'colorizer',
10593
'kwds': {},
@@ -109,16 +97,6 @@ def _wrapper(parent): # htest #
10997
"The default color scheme is in idlelib/config-highlight.def"
11098
}
11199

112-
CustomRun_spec = {
113-
'file': 'query',
114-
'kwds': {'title': 'Customize query.py Run',
115-
'_htest': True},
116-
'msg': "Enter with <Return> or [Run]. Print valid entry to Shell\n"
117-
"Arguments are parsed into a list\n"
118-
"Mode is currently restart True or False\n"
119-
"Close dialog with valid entry, <Escape>, [Cancel], [X]"
120-
}
121-
122100
ConfigDialog_spec = {
123101
'file': 'configdialog',
124102
'kwds': {'title': 'ConfigDialogTest',
@@ -135,6 +113,16 @@ def _wrapper(parent): # htest #
135113
"changes made have persisted."
136114
}
137115

116+
CustomRun_spec = {
117+
'file': 'query',
118+
'kwds': {'title': 'Customize query.py Run',
119+
'_htest': True},
120+
'msg': "Enter with <Return> or [Run]. Print valid entry to Shell\n"
121+
"Arguments are parsed into a list\n"
122+
"Mode is currently restart True or False\n"
123+
"Close dialog with valid entry, <Escape>, [Cancel], [X]"
124+
}
125+
138126
# TODO Improve message
139127
_dyn_option_menu_spec = {
140128
'file': 'dynoption',
@@ -236,6 +224,15 @@ def _wrapper(parent): # htest #
236224
"focusing out of the window\nare sequences to be tested."
237225
}
238226

227+
_module_browser_spec = {
228+
'file': 'browser',
229+
'kwds': {},
230+
'msg': "Inspect names of module, class(with superclass if "
231+
"applicable), methods and functions.\nToggle nested items.\n"
232+
"Double clicking on items prints a traceback for an exception "
233+
"that is ignored."
234+
}
235+
239236
_multistatus_bar_spec = {
240237
'file': 'statusbar',
241238
'kwds': {},

0 commit comments

Comments
 (0)