MCPcopy Index your code
hub / github.com/python/cpython / run

Function run

Lib/idlelib/idle_test/htest.py:368–438  ·  view source on GitHub ↗

Run callables in tests.

(*tests)

Source from the content-addressed store, hash-verified

366 }
367
368def run(*tests):
369 "Run callables in tests."
370 root = tk.Tk()
371 root.title('IDLE htest')
372 root.resizable(0, 0)
373
374 # A scrollable Label-like constant width text widget.
375 frameLabel = tk.Frame(root, padx=10)
376 frameLabel.pack()
377 text = tk.Text(frameLabel, wrap='word')
378 text.configure(bg=root.cget('bg'), relief='flat', height=4, width=70)
379 scrollbar = Scrollbar(frameLabel, command=text.yview)
380 text.config(yscrollcommand=scrollbar.set)
381 scrollbar.pack(side='right', fill='y', expand=False)
382 text.pack(side='left', fill='both', expand=True)
383
384 test_list = [] # Make list of (spec, callable) tuples.
385 if tests:
386 for test in tests:
387 test_spec = globals()[test.__name__ + '_spec']
388 test_spec['name'] = test.__name__
389 test_list.append((test_spec, test))
390 else:
391 for key, dic in globals().items():
392 if key.endswith('_spec'):
393 test_name = key[:-5]
394 test_spec = dic
395 test_spec['name'] = test_name
396 mod = import_module('idlelib.' + test_spec['file'])
397 test = getattr(mod, test_name)
398 test_list.append((test_spec, test))
399 test_list.reverse() # So can pop in proper order in next_test.
400
401 test_name = tk.StringVar(root)
402 callable_object = None
403 test_kwds = None
404
405 def next_test():
406 nonlocal test_name, callable_object, test_kwds
407 if len(test_list) == 1:
408 next_button.pack_forget()
409 test_spec, callable_object = test_list.pop()
410 test_kwds = test_spec['kwds']
411 test_name.set('Test ' + test_spec['name'])
412
413 text['state'] = 'normal' # Enable text replacement.
414 text.delete('1.0', 'end')
415 text.insert("1.0", test_spec['msg'])
416 text['state'] = 'disabled' # Restore read-only property.
417
418 def run_test(_=None):
419 widget = callable_object(root, **test_kwds)
420 try:
421 print(widget.result) # Only true for query classes(?).
422 except AttributeError:
423 pass
424
425 def close(_=None):

Callers 15

statusbar.pyFile · 0.90
calltip_w.pyFile · 0.90
pathbrowser.pyFile · 0.90
dynoption.pyFile · 0.90
configdialog.pyFile · 0.90
help.pyFile · 0.90
debugobj.pyFile · 0.90
sidebar.pyFile · 0.90
tree.pyFile · 0.90
colorizer.pyFile · 0.90
config_key.pyFile · 0.90
grep.pyFile · 0.90

Calls 15

ScrollbarClass · 0.90
import_moduleFunction · 0.90
next_testFunction · 0.85
titleMethod · 0.45
packMethod · 0.45
configureMethod · 0.45
cgetMethod · 0.45
configMethod · 0.45
appendMethod · 0.45
itemsMethod · 0.45
endswithMethod · 0.45
reverseMethod · 0.45

Tested by

no test coverage detected