8
8
9
9
In a tested module, let X be a global name bound to a callable (class or
10
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.
11
+ first parameter of X must be 'parent' or 'master'. When called, the
12
+ first argument will be the root window. X must create a child
13
+ Toplevel(parent/master) (or subclass thereof). The Toplevel may be a
14
+ test widget or dialog, in which case the callable is the corresponding
15
+ class. Or the Toplevel may contain the widget to be tested or set up a
16
+ context in which a test widget is invoked. In this latter case, the
17
+ callable is a wrapper function that sets up the Toplevel and other
18
+ objects. Wrapper function names, such as _editor_window', should start
19
+ with '_' and be lowercase.
19
20
20
21
21
22
End the module with
117
118
'file' : 'query' ,
118
119
'kwds' : {'title' : 'Customize query.py Run' ,
119
120
'_htest' : True },
120
- 'msg' : "Enter with <Return> or [Run ]. Print valid entry to Shell\n "
121
+ 'msg' : "Enter with <Return> or [OK ]. Print valid entry to Shell\n "
121
122
"Arguments are parsed into a list\n "
122
123
"Mode is currently restart True or False\n "
123
124
"Close dialog with valid entry, <Escape>, [Cancel], [X]"
124
125
}
125
126
127
+ _debug_object_browser_spec = {
128
+ 'file' : 'debugobj' ,
129
+ 'kwds' : {},
130
+ 'msg' : "Double click on items up to the lowest level.\n "
131
+ "Attributes of the objects and related information "
132
+ "will be displayed side-by-side at each level."
133
+ }
134
+
126
135
# TODO Improve message
127
136
_dyn_option_menu_spec = {
128
137
'file' : 'dynoption' ,
178
187
"Any url ('www...', 'http...') is accepted.\n "
179
188
"Test Browse with and without path, as cannot unittest.\n "
180
189
"[Ok] or <Return> prints valid entry to shell\n "
181
- "[Cancel] or <Escape> prints None to shell"
190
+ "<Escape>, [Cancel], or [X] prints None to shell"
182
191
}
183
192
184
193
_io_binding_spec = {
199
208
'kwds' : {},
200
209
'msg' : textwrap .dedent ("""\
201
210
1. Click on the line numbers and drag down below the edge of the
202
- window, moving the mouse a bit and then leaving it there for a while.
203
- The text and line numbers should gradually scroll down, with the
204
- selection updated continuously.
211
+ window, moving the mouse a bit and then leaving it there for a
212
+ while. The text and line numbers should gradually scroll down,
213
+ with the selection updated continuously.
205
214
206
- 2. With the lines still selected, click on a line number above the
207
- selected lines. Only the line whose number was clicked should be
208
- selected.
215
+ 2. With the lines still selected, click on a line number above
216
+ or below the selected lines. Only the line whose number was
217
+ clicked should be selected.
209
218
210
- 3. Repeat step #1, dragging to above the window. The text and line
211
- numbers should gradually scroll up, with the selection updated
212
- continuously.
219
+ 3. Repeat step #1, dragging to above the window. The text and
220
+ line numbers should gradually scroll up, with the selection
221
+ updated continuously.
213
222
214
223
4. Repeat step #2, clicking a line number below the selection.""" ),
215
224
}
216
225
217
226
_multi_call_spec = {
218
227
'file' : 'multicall' ,
219
228
'kwds' : {},
220
- 'msg' : "The following actions should trigger a print to console or IDLE"
221
- " Shell.\n Entering and leaving the text area, key entry, "
222
- "<Control-Key>,\n <Alt-Key-a>, <Control-Key-a>, "
223
- "<Alt-Control-Key-a>, \n <Control-Button-1>, <Alt-Button-1> and "
224
- "focusing out of the window\n are sequences to be tested."
229
+ 'msg' : "The following should trigger a print to console or IDLE Shell.\n "
230
+ "Entering and leaving the text area, key entry, <Control-Key>,\n "
231
+ "<Alt-Key-a>, <Control-Key-a>, <Alt-Control-Key-a>, \n "
232
+ "<Control-Button-1>, <Alt-Button-1> and focusing elsewhere."
225
233
}
226
234
227
235
_module_browser_spec = {
228
236
'file' : 'browser' ,
229
237
'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."
238
+ 'msg' : textwrap . dedent ( "" "
239
+ "Inspect names of module, class(with superclass if applicable),
240
+ "methods and functions. Toggle nested items. Double clicking
241
+ "on items prints a traceback for an exception that is ignored.""" )
234
242
}
235
243
236
244
_multistatus_bar_spec = {
237
245
'file' : 'statusbar' ,
238
246
'kwds' : {},
239
247
'msg' : "Ensure presence of multi-status bar below text area.\n "
240
- "Click 'Update Status' to change the multi-status text"
241
- }
242
-
243
- _object_browser_spec = {
244
- 'file' : 'debugobj' ,
245
- 'kwds' : {},
246
- 'msg' : "Double click on items up to the lowest level.\n "
247
- "Attributes of the objects and related information "
248
- "will be displayed side-by-side at each level."
248
+ "Click 'Update Status' to change the status text"
249
249
}
250
250
251
- _path_browser_spec = {
251
+ PathBrowser_spec = {
252
252
'file' : 'pathbrowser' ,
253
- 'kwds' : {},
253
+ 'kwds' : {'_htest' : True },
254
254
'msg' : "Test for correct display of all paths in sys.path.\n "
255
- "Toggle nested items up to the lowest level.\n "
255
+ "Toggle nested items out to the lowest level.\n "
256
256
"Double clicking on an item prints a traceback\n "
257
257
"for an exception that is ignored."
258
258
}
367
367
}
368
368
369
369
def run (* tests ):
370
+ "Run callables in tests."
370
371
root = tk .Tk ()
371
372
root .title ('IDLE htest' )
372
373
root .resizable (0 , 0 )
373
374
374
- # a scrollable Label like constant width text widget.
375
+ # A scrollable Label- like constant width text widget.
375
376
frameLabel = tk .Frame (root , padx = 10 )
376
377
frameLabel .pack ()
377
378
text = tk .Text (frameLabel , wrap = 'word' )
@@ -381,45 +382,44 @@ def run(*tests):
381
382
scrollbar .pack (side = 'right' , fill = 'y' , expand = False )
382
383
text .pack (side = 'left' , fill = 'both' , expand = True )
383
384
384
- test_list = [] # List of tuples of the form (spec, callable widget)
385
+ test_list = [] # Make list of (spec, callable) tuples.
385
386
if tests :
386
387
for test in tests :
387
388
test_spec = globals ()[test .__name__ + '_spec' ]
388
389
test_spec ['name' ] = test .__name__
389
390
test_list .append ((test_spec , test ))
390
391
else :
391
- for k , d in globals ().items ():
392
- if k .endswith ('_spec' ):
393
- test_name = k [:- 5 ]
394
- test_spec = d
392
+ for key , dic in globals ().items ():
393
+ if key .endswith ('_spec' ):
394
+ test_name = key [:- 5 ]
395
+ test_spec = dic
395
396
test_spec ['name' ] = test_name
396
397
mod = import_module ('idlelib.' + test_spec ['file' ])
397
398
test = getattr (mod , test_name )
398
399
test_list .append ((test_spec , test ))
400
+ test_list .reverse () # So can pop in proper order in next_test.
399
401
400
402
test_name = tk .StringVar (root )
401
403
callable_object = None
402
404
test_kwds = None
403
405
404
406
def next_test ():
405
-
406
407
nonlocal test_name , callable_object , test_kwds
407
408
if len (test_list ) == 1 :
408
409
next_button .pack_forget ()
409
410
test_spec , callable_object = test_list .pop ()
410
411
test_kwds = test_spec ['kwds' ]
411
- test_kwds ['parent' ] = root
412
412
test_name .set ('Test ' + test_spec ['name' ])
413
413
414
- text . configure ( state = 'normal' ) # enable text editing
415
- text .delete ('1.0' ,'end' )
416
- text .insert ("1.0" ,test_spec ['msg' ])
417
- text . configure ( state = 'disabled' ) # preserve read-only property
414
+ text [ ' state' ] = 'normal' # Enable text replacement.
415
+ text .delete ('1.0' , 'end' )
416
+ text .insert ("1.0" , test_spec ['msg' ])
417
+ text [ ' state' ] = 'disabled' # Restore read-only property.
418
418
419
419
def run_test (_ = None ):
420
- widget = callable_object (** test_kwds )
420
+ widget = callable_object (root , ** test_kwds )
421
421
try :
422
- print (widget .result )
422
+ print (widget .result ) # Only true for query classes(?).
423
423
except AttributeError :
424
424
pass
425
425
0 commit comments