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.
20
19
21
20
22
21
End the module with
23
22
24
23
if __name__ == '__main__':
25
- <unittest, if there is one >
24
+ <run unittest.main with 'exit=False' >
26
25
from idlelib.idle_test.htest import run
27
- run(X)
26
+ run(callable) # There could be multiple comma-separated callables.
28
27
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:
36
33
37
34
[report]
38
35
exclude_lines =
@@ -46,24 +43,24 @@ def _wrapper(parent): # htest #
46
43
following template, with X.__name__ prepended to '_spec'.
47
44
When all tests are run, the prefix is use to get X.
48
45
49
- _spec = {
46
+ callable_spec = {
50
47
'file': '',
51
48
'kwds': {'title': ''},
52
49
'msg': ""
53
50
}
54
51
55
52
file (no .py): run() imports file.py.
56
53
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.
58
55
msg: master window hints about testing the widget.
59
56
60
57
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
+ """
67
64
68
65
import idlelib .pyshell # Set Windows DPI awareness before Tk().
69
66
from importlib import import_module
@@ -91,15 +88,6 @@ def _wrapper(parent): # htest #
91
88
"Force-open-calltip does not work here.\n "
92
89
}
93
90
94
- _module_browser_spec = {
95
- 'file' : 'browser' ,
96
- 'kwds' : {},
97
- 'msg' : "Inspect names of module, class(with superclass if "
98
- "applicable), methods and functions.\n Toggle nested items.\n "
99
- "Double clicking on items prints a traceback for an exception "
100
- "that is ignored."
101
- }
102
-
103
91
_color_delegator_spec = {
104
92
'file' : 'colorizer' ,
105
93
'kwds' : {},
@@ -109,16 +97,6 @@ def _wrapper(parent): # htest #
109
97
"The default color scheme is in idlelib/config-highlight.def"
110
98
}
111
99
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
-
122
100
ConfigDialog_spec = {
123
101
'file' : 'configdialog' ,
124
102
'kwds' : {'title' : 'ConfigDialogTest' ,
@@ -135,6 +113,16 @@ def _wrapper(parent): # htest #
135
113
"changes made have persisted."
136
114
}
137
115
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
+
138
126
# TODO Improve message
139
127
_dyn_option_menu_spec = {
140
128
'file' : 'dynoption' ,
@@ -236,6 +224,15 @@ def _wrapper(parent): # htest #
236
224
"focusing out of the window\n are sequences to be tested."
237
225
}
238
226
227
+ _module_browser_spec = {
228
+ 'file' : 'browser' ,
229
+ 'kwds' : {},
230
+ 'msg' : "Inspect names of module, class(with superclass if "
231
+ "applicable), methods and functions.\n Toggle nested items.\n "
232
+ "Double clicking on items prints a traceback for an exception "
233
+ "that is ignored."
234
+ }
235
+
239
236
_multistatus_bar_spec = {
240
237
'file' : 'statusbar' ,
241
238
'kwds' : {},
0 commit comments