2014-05-15 21:50:10 -03:00
|
|
|
'''Run human tests of Idle's window, dialog, and popup widgets.
|
2014-05-12 00:32:32 -03:00
|
|
|
|
2014-06-01 01:30:34 -03:00
|
|
|
run(*tests)
|
2014-10-17 02:31:35 -03:00
|
|
|
Create a master Tk window. Within that, run each callable in tests
|
|
|
|
after finding the matching test spec in this file. If tests is empty,
|
|
|
|
run an htest for each spec dict in this file after finding the matching
|
|
|
|
callable in the module named in the spec. Close the window to skip or
|
|
|
|
end the test.
|
|
|
|
|
|
|
|
In a tested module, let X be a global name bound to a callable (class
|
2017-06-29 19:42:17 -03:00
|
|
|
or function) whose .__name__ attribute is also X (the usual situation).
|
2014-10-17 02:31:35 -03:00
|
|
|
The first parameter of X must be 'parent'. When called, the parent
|
|
|
|
argument will be the root window. X must create a child Toplevel
|
|
|
|
window (or subclass thereof). The Toplevel may be a test widget or
|
|
|
|
dialog, in which case the callable is the corresonding class. Or the
|
|
|
|
Toplevel may contain the widget to be tested or set up a context in
|
|
|
|
which a test widget is invoked. In this latter case, the callable is a
|
|
|
|
wrapper function that sets up the Toplevel and other objects. Wrapper
|
|
|
|
function names, such as _editor_window', should start with '_'.
|
|
|
|
|
2014-05-15 21:50:10 -03:00
|
|
|
|
2014-06-01 01:30:34 -03:00
|
|
|
End the module with
|
2014-05-12 00:32:32 -03:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
<unittest, if there is one>
|
|
|
|
from idlelib.idle_test.htest import run
|
|
|
|
run(X)
|
|
|
|
|
2014-10-17 02:31:35 -03:00
|
|
|
To have wrapper functions and test invocation code ignored by coveragepy
|
|
|
|
reports, put '# htest #' on the def statement header line.
|
|
|
|
|
|
|
|
def _wrapper(parent): # htest #
|
|
|
|
|
|
|
|
Also make sure that the 'if __name__' line matches the above. Then have
|
|
|
|
make sure that .coveragerc includes the following.
|
|
|
|
|
|
|
|
[report]
|
|
|
|
exclude_lines =
|
|
|
|
.*# htest #
|
|
|
|
if __name__ == .__main__.:
|
2014-05-15 21:50:10 -03:00
|
|
|
|
2014-10-17 02:31:35 -03:00
|
|
|
(The "." instead of "'" is intentional and necessary.)
|
|
|
|
|
|
|
|
|
|
|
|
To run any X, this file must contain a matching instance of the
|
|
|
|
following template, with X.__name__ prepended to '_spec'.
|
|
|
|
When all tests are run, the prefix is use to get X.
|
2014-05-15 21:50:10 -03:00
|
|
|
|
2014-05-12 00:32:32 -03:00
|
|
|
_spec = {
|
|
|
|
'file': '',
|
|
|
|
'kwds': {'title': ''},
|
|
|
|
'msg': ""
|
|
|
|
}
|
2014-05-15 21:50:10 -03:00
|
|
|
|
2014-10-17 02:31:35 -03:00
|
|
|
file (no .py): run() imports file.py.
|
|
|
|
kwds: augmented with {'parent':root} and passed to X as **kwds.
|
|
|
|
title: an example kwd; some widgets need this, delete if not.
|
|
|
|
msg: master window hints about testing the widget.
|
2014-06-01 01:30:34 -03:00
|
|
|
|
2014-10-17 02:31:35 -03:00
|
|
|
|
|
|
|
Modules and classes not being tested at the moment:
|
2016-05-28 14:22:31 -03:00
|
|
|
pyshell.PyShellEditorWindow
|
|
|
|
debugger.Debugger
|
|
|
|
autocomplete_w.AutoCompleteWindow
|
|
|
|
outwin.OutputWindow (indirectly being tested with grep test)
|
2014-05-12 00:32:32 -03:00
|
|
|
'''
|
2014-10-17 02:31:35 -03:00
|
|
|
|
2014-05-12 00:32:32 -03:00
|
|
|
from importlib import import_module
|
|
|
|
import tkinter as tk
|
2016-06-10 19:19:21 -03:00
|
|
|
from tkinter.ttk import Scrollbar
|
2016-06-21 19:41:38 -03:00
|
|
|
tk.NoDefaultRoot()
|
2014-05-12 00:32:32 -03:00
|
|
|
|
|
|
|
AboutDialog_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'help_about',
|
|
|
|
'kwds': {'title': 'help_about test',
|
2014-05-24 19:48:18 -03:00
|
|
|
'_htest': True,
|
|
|
|
},
|
|
|
|
'msg': "Test every button. Ensure Python, TK and IDLE versions "
|
|
|
|
"are correctly displayed.\n [Close] to exit.",
|
2014-06-01 01:30:34 -03:00
|
|
|
}
|
2014-05-24 19:48:18 -03:00
|
|
|
|
|
|
|
_calltip_window_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'calltip_w',
|
2014-05-24 19:48:18 -03:00
|
|
|
'kwds': {},
|
|
|
|
'msg': "Typing '(' should display a calltip.\n"
|
|
|
|
"Typing ') should hide the calltip.\n"
|
2014-05-12 00:32:32 -03:00
|
|
|
}
|
|
|
|
|
2017-09-23 17:46:01 -03:00
|
|
|
_module_browser_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'browser',
|
2014-05-24 19:48:18 -03:00
|
|
|
'kwds': {},
|
|
|
|
'msg': "Inspect names of module, class(with superclass if "
|
2014-05-25 19:44:05 -03:00
|
|
|
"applicable), methods and functions.\nToggle nested items.\n"
|
2014-05-27 04:30:54 -03:00
|
|
|
"Double clicking on items prints a traceback for an exception "
|
|
|
|
"that is ignored."
|
|
|
|
}
|
2014-05-12 00:32:32 -03:00
|
|
|
|
2014-05-24 19:48:18 -03:00
|
|
|
_color_delegator_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'colorizer',
|
2014-05-24 19:48:18 -03:00
|
|
|
'kwds': {},
|
|
|
|
'msg': "The text is sample Python code.\n"
|
|
|
|
"Ensure components like comments, keywords, builtins,\n"
|
|
|
|
"string, definitions, and break are correctly colored.\n"
|
|
|
|
"The default color scheme is in idlelib/config-highlight.def"
|
|
|
|
}
|
|
|
|
|
2014-05-29 02:46:26 -03:00
|
|
|
ConfigDialog_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'configdialog',
|
2014-10-17 02:31:35 -03:00
|
|
|
'kwds': {'title': 'ConfigDialogTest',
|
2014-05-29 02:46:26 -03:00
|
|
|
'_htest': True,},
|
|
|
|
'msg': "IDLE preferences dialog.\n"
|
|
|
|
"In the 'Fonts/Tabs' tab, changing font face, should update the "
|
|
|
|
"font face of the text in the area below it.\nIn the "
|
|
|
|
"'Highlighting' tab, try different color schemes. Clicking "
|
|
|
|
"items in the sample program should update the choices above it."
|
2015-10-13 23:03:51 -03:00
|
|
|
"\nIn the 'Keys', 'General' and 'Extensions' tabs, test settings"
|
|
|
|
"of interest."
|
2014-05-29 02:46:26 -03:00
|
|
|
"\n[Ok] to close the dialog.[Apply] to apply the settings and "
|
|
|
|
"and [Cancel] to revert all changes.\nRe-run the test to ensure "
|
|
|
|
"changes made have persisted."
|
|
|
|
}
|
|
|
|
|
2014-10-17 02:31:35 -03:00
|
|
|
# TODO Improve message
|
2014-05-24 19:48:18 -03:00
|
|
|
_dyn_option_menu_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'dynoption',
|
2014-05-19 01:12:10 -03:00
|
|
|
'kwds': {},
|
2014-05-24 19:48:18 -03:00
|
|
|
'msg': "Select one of the many options in the 'old option set'.\n"
|
|
|
|
"Click the button to change the option set.\n"
|
|
|
|
"Select one of the many options in the 'new option set'."
|
2014-05-19 01:12:10 -03:00
|
|
|
}
|
|
|
|
|
2014-10-17 02:31:35 -03:00
|
|
|
# TODO edit wrapper
|
2014-05-25 19:44:05 -03:00
|
|
|
_editor_window_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'editor',
|
2014-05-25 19:44:05 -03:00
|
|
|
'kwds': {},
|
2014-10-17 02:31:35 -03:00
|
|
|
'msg': "Test editor functions of interest.\n"
|
|
|
|
"Best to close editor first."
|
2014-05-25 19:44:05 -03:00
|
|
|
}
|
2014-05-24 19:48:18 -03:00
|
|
|
|
2014-05-25 19:44:05 -03:00
|
|
|
# Update once issue21519 is resolved.
|
|
|
|
GetKeysDialog_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'config_key',
|
2014-05-25 19:44:05 -03:00
|
|
|
'kwds': {'title': 'Test keybindings',
|
|
|
|
'action': 'find-again',
|
|
|
|
'currentKeySequences': [''] ,
|
|
|
|
'_htest': True,
|
|
|
|
},
|
|
|
|
'msg': "Test for different key modifier sequences.\n"
|
|
|
|
"<nothing> is invalid.\n"
|
|
|
|
"No modifier key is invalid.\n"
|
|
|
|
"Shift key with [a-z],[0-9], function key, move key, tab, space"
|
2014-10-19 12:04:38 -03:00
|
|
|
"is invalid.\nNo validity checking if advanced key binding "
|
2014-05-25 19:44:05 -03:00
|
|
|
"entry is used."
|
|
|
|
}
|
|
|
|
|
2014-05-29 02:46:26 -03:00
|
|
|
_grep_dialog_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'grep',
|
2014-05-29 02:46:26 -03:00
|
|
|
'kwds': {},
|
|
|
|
'msg': "Click the 'Show GrepDialog' button.\n"
|
|
|
|
"Test the various 'Find-in-files' functions.\n"
|
|
|
|
"The results should be displayed in a new '*Output*' window.\n"
|
|
|
|
"'Right-click'->'Goto file/line' anywhere in the search results "
|
|
|
|
"should open that file \nin a new EditorWindow."
|
|
|
|
}
|
|
|
|
|
2016-07-08 01:22:50 -03:00
|
|
|
HelpSource_spec = {
|
|
|
|
'file': 'query',
|
|
|
|
'kwds': {'title': 'Help name and source',
|
|
|
|
'menuitem': 'test',
|
|
|
|
'filepath': __file__,
|
|
|
|
'used_names': {'abc'},
|
|
|
|
'_htest': True},
|
|
|
|
'msg': "Enter menu item name and help file path\n"
|
|
|
|
"'', > than 30 chars, and 'abc' are invalid menu item names.\n"
|
|
|
|
"'' and file does not exist are invalid path items.\n"
|
|
|
|
"Any url ('www...', 'http...') is accepted.\n"
|
|
|
|
"Test Browse with and without path, as cannot unittest.\n"
|
2016-07-25 21:58:43 -03:00
|
|
|
"[Ok] or <Return> prints valid entry to shell\n"
|
|
|
|
"[Cancel] or <Escape> prints None to shell"
|
2016-07-08 01:22:50 -03:00
|
|
|
}
|
|
|
|
|
2014-05-24 19:48:18 -03:00
|
|
|
_io_binding_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'iomenu',
|
2014-05-24 19:48:18 -03:00
|
|
|
'kwds': {},
|
2015-10-30 03:47:06 -03:00
|
|
|
'msg': "Test the following bindings.\n"
|
|
|
|
"<Control-o> to open file from dialog.\n"
|
|
|
|
"Edit the file.\n"
|
2016-01-27 12:51:50 -04:00
|
|
|
"<Control-p> to print the file.\n"
|
2015-10-30 03:47:06 -03:00
|
|
|
"<Control-s> to save the file.\n"
|
2016-01-27 12:51:50 -04:00
|
|
|
"<Alt-s> to save-as another file.\n"
|
|
|
|
"<Control-c> to save-copy-as another file.\n"
|
2015-10-30 03:47:06 -03:00
|
|
|
"Check that changes were saved by opening the file elsewhere."
|
2014-05-24 19:48:18 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
_multi_call_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'multicall',
|
2014-05-24 19:48:18 -03:00
|
|
|
'kwds': {},
|
2014-05-25 19:44:05 -03:00
|
|
|
'msg': "The following actions should trigger a print to console or IDLE"
|
|
|
|
" Shell.\nEntering and leaving the text area, key entry, "
|
|
|
|
"<Control-Key>,\n<Alt-Key-a>, <Control-Key-a>, "
|
|
|
|
"<Alt-Control-Key-a>, \n<Control-Button-1>, <Alt-Button-1> and "
|
|
|
|
"focusing out of the window\nare sequences to be tested."
|
2014-05-24 19:48:18 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
_multistatus_bar_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'statusbar',
|
2014-05-24 19:48:18 -03:00
|
|
|
'kwds': {},
|
|
|
|
'msg': "Ensure presence of multi-status bar below text area.\n"
|
|
|
|
"Click 'Update Status' to change the multi-status text"
|
|
|
|
}
|
|
|
|
|
|
|
|
_object_browser_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'debugobj',
|
2014-05-24 19:48:18 -03:00
|
|
|
'kwds': {},
|
|
|
|
'msg': "Double click on items upto the lowest level.\n"
|
|
|
|
"Attributes of the objects and related information "
|
|
|
|
"will be displayed side-by-side at each level."
|
|
|
|
}
|
|
|
|
|
|
|
|
_path_browser_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'pathbrowser',
|
2014-05-24 19:48:18 -03:00
|
|
|
'kwds': {},
|
2014-05-25 19:44:05 -03:00
|
|
|
'msg': "Test for correct display of all paths in sys.path.\n"
|
|
|
|
"Toggle nested items upto the lowest level.\n"
|
|
|
|
"Double clicking on an item prints a traceback\n"
|
|
|
|
"for an exception that is ignored."
|
|
|
|
}
|
|
|
|
|
|
|
|
_percolator_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'percolator',
|
2014-05-25 19:44:05 -03:00
|
|
|
'kwds': {},
|
|
|
|
'msg': "There are two tracers which can be toggled using a checkbox.\n"
|
|
|
|
"Toggling a tracer 'on' by checking it should print tracer"
|
|
|
|
"output to the console or to the IDLE shell.\n"
|
|
|
|
"If both the tracers are 'on', the output from the tracer which "
|
|
|
|
"was switched 'on' later, should be printed first\n"
|
|
|
|
"Test for actions like text entry, and removal."
|
2014-05-24 19:48:18 -03:00
|
|
|
}
|
|
|
|
|
2016-06-26 23:05:10 -03:00
|
|
|
Query_spec = {
|
|
|
|
'file': 'query',
|
2016-07-03 20:11:13 -03:00
|
|
|
'kwds': {'title': 'Query',
|
|
|
|
'message': 'Enter something',
|
|
|
|
'text0': 'Go',
|
2016-06-26 23:05:10 -03:00
|
|
|
'_htest': True},
|
|
|
|
'msg': "Enter with <Return> or [Ok]. Print valid entry to Shell\n"
|
|
|
|
"Blank line, after stripping, is ignored\n"
|
2016-07-25 21:58:43 -03:00
|
|
|
"Close dialog with valid entry, <Escape>, [Cancel], [X]"
|
2016-06-26 23:05:10 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-27 04:30:54 -03:00
|
|
|
_replace_dialog_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'replace',
|
2014-05-27 04:30:54 -03:00
|
|
|
'kwds': {},
|
|
|
|
'msg': "Click the 'Replace' button.\n"
|
|
|
|
"Test various replace options in the 'Replace dialog'.\n"
|
2014-06-01 01:30:34 -03:00
|
|
|
"Click [Close] or [X] to close the 'Replace Dialog'."
|
2014-05-27 04:30:54 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
_search_dialog_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'search',
|
2014-05-27 04:30:54 -03:00
|
|
|
'kwds': {},
|
|
|
|
'msg': "Click the 'Search' button.\n"
|
|
|
|
"Test various search options in the 'Search dialog'.\n"
|
2014-06-01 01:30:34 -03:00
|
|
|
"Click [Close] or [X] to close the 'Search Dialog'."
|
2014-05-27 04:30:54 -03:00
|
|
|
}
|
|
|
|
|
2016-07-10 21:21:31 -03:00
|
|
|
_searchbase_spec = {
|
|
|
|
'file': 'searchbase',
|
|
|
|
'kwds': {},
|
|
|
|
'msg': "Check the appearance of the base search dialog\n"
|
|
|
|
"Its only action is to close."
|
|
|
|
}
|
|
|
|
|
2014-05-24 19:48:18 -03:00
|
|
|
_scrolled_list_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'scrolledlist',
|
2014-05-24 19:48:18 -03:00
|
|
|
'kwds': {},
|
|
|
|
'msg': "You should see a scrollable list of items\n"
|
2014-05-25 19:44:05 -03:00
|
|
|
"Selecting (clicking) or double clicking an item "
|
|
|
|
"prints the name to the console or Idle shell.\n"
|
|
|
|
"Right clicking an item will display a popup."
|
|
|
|
}
|
|
|
|
|
2015-09-20 20:57:13 -03:00
|
|
|
show_idlehelp_spec = {
|
|
|
|
'file': 'help',
|
|
|
|
'kwds': {},
|
|
|
|
'msg': "If the help text displays, this works.\n"
|
|
|
|
"Text is selectable. Window is scrollable."
|
|
|
|
}
|
|
|
|
|
2014-05-25 19:44:05 -03:00
|
|
|
_stack_viewer_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'stackviewer',
|
2014-05-25 19:44:05 -03:00
|
|
|
'kwds': {},
|
|
|
|
'msg': "A stacktrace for a NameError exception.\n"
|
|
|
|
"Expand 'idlelib ...' and '<locals>'.\n"
|
|
|
|
"Check that exc_value, exc_tb, and exc_type are correct.\n"
|
2014-05-24 19:48:18 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
_tabbed_pages_spec = {
|
|
|
|
'file': 'tabbedpages',
|
|
|
|
'kwds': {},
|
|
|
|
'msg': "Toggle between the two tabs 'foo' and 'bar'\n"
|
|
|
|
"Add a tab by entering a suitable name for it.\n"
|
|
|
|
"Remove an existing tab by entering its name.\n"
|
|
|
|
"Remove all existing tabs.\n"
|
|
|
|
"<nothing> is an invalid add page and remove page name.\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
_tooltip_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'tooltip',
|
2014-05-24 19:48:18 -03:00
|
|
|
'kwds': {},
|
|
|
|
'msg': "Place mouse cursor over both the buttons\n"
|
|
|
|
"A tooltip should appear with some text."
|
|
|
|
}
|
|
|
|
|
|
|
|
_tree_widget_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'tree',
|
2014-05-24 19:48:18 -03:00
|
|
|
'kwds': {},
|
2014-05-27 04:30:54 -03:00
|
|
|
'msg': "The canvas is scrollable.\n"
|
2014-05-24 19:48:18 -03:00
|
|
|
"Click on folders upto to the lowest level."
|
|
|
|
}
|
|
|
|
|
2014-05-29 02:46:26 -03:00
|
|
|
_undo_delegator_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'undo',
|
2014-05-29 02:46:26 -03:00
|
|
|
'kwds': {},
|
|
|
|
'msg': "Click [Undo] to undo any action.\n"
|
|
|
|
"Click [Redo] to redo any action.\n"
|
|
|
|
"Click [Dump] to dump the current state "
|
|
|
|
"by printing to the console or the IDLE shell.\n"
|
|
|
|
}
|
|
|
|
|
2017-06-29 19:42:17 -03:00
|
|
|
ViewWindow_spec = {
|
|
|
|
'file': 'textview',
|
|
|
|
'kwds': {'title': 'Test textview',
|
|
|
|
'text': 'The quick brown fox jumps over the lazy dog.\n'*35,
|
|
|
|
'_htest': True},
|
|
|
|
'msg': "Test for read-only property of text.\n"
|
|
|
|
"Select text, scroll window, close"
|
|
|
|
}
|
|
|
|
|
2014-05-24 19:48:18 -03:00
|
|
|
_widget_redirector_spec = {
|
2016-05-28 14:22:31 -03:00
|
|
|
'file': 'redirector',
|
2014-05-24 19:48:18 -03:00
|
|
|
'kwds': {},
|
2014-05-25 19:44:05 -03:00
|
|
|
'msg': "Every text insert should be printed to the console."
|
|
|
|
"or the IDLE shell."
|
2014-05-24 19:48:18 -03:00
|
|
|
}
|
|
|
|
|
2014-05-25 19:44:05 -03:00
|
|
|
def run(*tests):
|
2014-05-12 00:32:32 -03:00
|
|
|
root = tk.Tk()
|
2014-05-29 02:46:26 -03:00
|
|
|
root.title('IDLE htest')
|
|
|
|
root.resizable(0, 0)
|
|
|
|
|
|
|
|
# a scrollable Label like constant width text widget.
|
|
|
|
frameLabel = tk.Frame(root, padx=10)
|
|
|
|
frameLabel.pack()
|
|
|
|
text = tk.Text(frameLabel, wrap='word')
|
|
|
|
text.configure(bg=root.cget('bg'), relief='flat', height=4, width=70)
|
2016-06-10 19:19:21 -03:00
|
|
|
scrollbar = Scrollbar(frameLabel, command=text.yview)
|
2014-05-29 02:46:26 -03:00
|
|
|
text.config(yscrollcommand=scrollbar.set)
|
|
|
|
scrollbar.pack(side='right', fill='y', expand=False)
|
|
|
|
text.pack(side='left', fill='both', expand=True)
|
|
|
|
|
2014-05-25 19:44:05 -03:00
|
|
|
test_list = [] # List of tuples of the form (spec, callable widget)
|
|
|
|
if tests:
|
|
|
|
for test in tests:
|
|
|
|
test_spec = globals()[test.__name__ + '_spec']
|
|
|
|
test_spec['name'] = test.__name__
|
|
|
|
test_list.append((test_spec, test))
|
2014-05-24 19:48:18 -03:00
|
|
|
else:
|
|
|
|
for k, d in globals().items():
|
|
|
|
if k.endswith('_spec'):
|
|
|
|
test_name = k[:-5]
|
|
|
|
test_spec = d
|
|
|
|
test_spec['name'] = test_name
|
|
|
|
mod = import_module('idlelib.' + test_spec['file'])
|
|
|
|
test = getattr(mod, test_name)
|
2014-05-25 19:44:05 -03:00
|
|
|
test_list.append((test_spec, test))
|
2014-05-24 19:48:18 -03:00
|
|
|
|
2016-06-21 19:41:38 -03:00
|
|
|
test_name = tk.StringVar(root)
|
2014-05-24 19:48:18 -03:00
|
|
|
callable_object = None
|
|
|
|
test_kwds = None
|
|
|
|
|
2016-07-27 23:17:05 -03:00
|
|
|
def next_test():
|
2014-05-29 02:46:26 -03:00
|
|
|
|
|
|
|
nonlocal test_name, callable_object, test_kwds
|
2014-05-24 19:48:18 -03:00
|
|
|
if len(test_list) == 1:
|
|
|
|
next_button.pack_forget()
|
2014-05-25 19:44:05 -03:00
|
|
|
test_spec, callable_object = test_list.pop()
|
|
|
|
test_kwds = test_spec['kwds']
|
|
|
|
test_kwds['parent'] = root
|
|
|
|
test_name.set('Test ' + test_spec['name'])
|
2014-05-24 19:48:18 -03:00
|
|
|
|
2014-05-29 02:46:26 -03:00
|
|
|
text.configure(state='normal') # enable text editing
|
|
|
|
text.delete('1.0','end')
|
|
|
|
text.insert("1.0",test_spec['msg'])
|
|
|
|
text.configure(state='disabled') # preserve read-only property
|
2014-05-15 21:50:10 -03:00
|
|
|
|
2016-07-27 23:17:05 -03:00
|
|
|
def run_test(_=None):
|
2014-05-24 19:48:18 -03:00
|
|
|
widget = callable_object(**test_kwds)
|
2014-05-12 00:32:32 -03:00
|
|
|
try:
|
|
|
|
print(widget.result)
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
|
2016-07-27 23:17:05 -03:00
|
|
|
def close(_=None):
|
|
|
|
root.destroy()
|
|
|
|
|
|
|
|
button = tk.Button(root, textvariable=test_name,
|
|
|
|
default='active', command=run_test)
|
|
|
|
next_button = tk.Button(root, text="Next", command=next_test)
|
2014-05-24 19:48:18 -03:00
|
|
|
button.pack()
|
|
|
|
next_button.pack()
|
2016-07-27 23:17:05 -03:00
|
|
|
next_button.focus_set()
|
|
|
|
root.bind('<Key-Return>', run_test)
|
|
|
|
root.bind('<Key-Escape>', close)
|
2014-05-24 19:48:18 -03:00
|
|
|
|
2016-07-27 23:17:05 -03:00
|
|
|
next_test()
|
2014-05-24 19:48:18 -03:00
|
|
|
root.mainloop()
|
2014-05-12 00:32:32 -03:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2014-05-24 19:48:18 -03:00
|
|
|
run()
|