summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/idle_test/htest.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/idlelib/idle_test/htest.py')
-rw-r--r--Lib/idlelib/idle_test/htest.py234
1 files changed, 96 insertions, 138 deletions
diff --git a/Lib/idlelib/idle_test/htest.py b/Lib/idlelib/idle_test/htest.py
index 1373b76..9e2ddd2 100644
--- a/Lib/idlelib/idle_test/htest.py
+++ b/Lib/idlelib/idle_test/htest.py
@@ -8,11 +8,11 @@ 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
-or function) whose .__name__ attribute is also X (the usual situation).
+or function) whose .__name__ attrubute is also X (the usual situation).
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 corresponding class. Or the
+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
@@ -59,40 +59,34 @@ msg: master window hints about testing the widget.
Modules and classes not being tested at the moment:
-pyshell.PyShellEditorWindow
-debugger.Debugger
-autocomplete_w.AutoCompleteWindow
-outwin.OutputWindow (indirectly being tested with grep test)
+PyShell.PyShellEditorWindow
+Debugger.Debugger
+AutoCompleteWindow.AutoCompleteWindow
+OutputWindow.OutputWindow (indirectly being tested with grep test)
'''
-import idlelib.pyshell # Set Windows DPI awareness before Tk().
from importlib import import_module
-import textwrap
-import tkinter as tk
-from tkinter.ttk import Scrollbar
-tk.NoDefaultRoot()
+from idlelib.macosxSupport import _initializeTkVariantTests
+import Tkinter as tk
AboutDialog_spec = {
- 'file': 'help_about',
- 'kwds': {'title': 'help_about test',
+ 'file': 'aboutDialog',
+ 'kwds': {'title': 'aboutDialog test',
'_htest': True,
},
'msg': "Test every button. Ensure Python, TK and IDLE versions "
"are correctly displayed.\n [Close] to exit.",
}
-# TODO implement ^\; adding '<Control-Key-\\>' to function does not work.
_calltip_window_spec = {
- 'file': 'calltip_w',
+ 'file': 'CallTipWindow',
'kwds': {},
'msg': "Typing '(' should display a calltip.\n"
"Typing ') should hide the calltip.\n"
- "So should moving cursor out of argument area.\n"
- "Force-open-calltip does not work here.\n"
}
-_module_browser_spec = {
- 'file': 'browser',
+_class_browser_spec = {
+ 'file': 'ClassBrowser',
'kwds': {},
'msg': "Inspect names of module, class(with superclass if "
"applicable), methods and functions.\nToggle nested items.\n"
@@ -101,7 +95,7 @@ _module_browser_spec = {
}
_color_delegator_spec = {
- 'file': 'colorizer',
+ 'file': 'ColorDelegator',
'kwds': {},
'msg': "The text is sample Python code.\n"
"Ensure components like comments, keywords, builtins,\n"
@@ -109,18 +103,8 @@ _color_delegator_spec = {
"The default color scheme is in idlelib/config-highlight.def"
}
-CustomRun_spec = {
- 'file': 'query',
- 'kwds': {'title': 'Customize query.py Run',
- '_htest': True},
- 'msg': "Enter with <Return> or [Run]. Print valid entry to Shell\n"
- "Arguments are parsed into a list\n"
- "Mode is currently restart True or False\n"
- "Close dialog with valid entry, <Escape>, [Cancel], [X]"
- }
-
ConfigDialog_spec = {
- 'file': 'configdialog',
+ 'file': 'configDialog',
'kwds': {'title': 'ConfigDialogTest',
'_htest': True,},
'msg': "IDLE preferences dialog.\n"
@@ -137,7 +121,7 @@ ConfigDialog_spec = {
# TODO Improve message
_dyn_option_menu_spec = {
- 'file': 'dynoption',
+ 'file': 'dynOptionMenuWidget',
'kwds': {},
'msg': "Select one of the many options in the 'old option set'.\n"
"Click the button to change the option set.\n"
@@ -146,55 +130,64 @@ _dyn_option_menu_spec = {
# TODO edit wrapper
_editor_window_spec = {
- 'file': 'editor',
+ 'file': 'EditorWindow',
'kwds': {},
'msg': "Test editor functions of interest.\n"
"Best to close editor first."
}
+GetCfgSectionNameDialog_spec = {
+ 'file': 'configSectionNameDialog',
+ 'kwds': {'title':'Get Name',
+ 'message':'Enter something',
+ 'used_names': {'abc'},
+ '_htest': True},
+ 'msg': "After the text entered with [Ok] is stripped, <nothing>, "
+ "'abc', or more that 30 chars are errors.\n"
+ "Close 'Get Name' with a valid entry (printed to Shell), "
+ "[Cancel], or [X]",
+ }
+
+GetHelpSourceDialog_spec = {
+ 'file': 'configHelpSourceEdit',
+ 'kwds': {'title': 'Get helpsource',
+ '_htest': True},
+ 'msg': "Enter menu item name and help file path\n "
+ "<nothing> and more than 30 chars are invalid menu item names.\n"
+ "<nothing>, file does not exist are invalid path items.\n"
+ "Test for incomplete web address for help file path.\n"
+ "A valid entry will be printed to shell with [0k].\n"
+ "[Cancel] will print None to shell",
+ }
+
+# Update once issue21519 is resolved.
GetKeysDialog_spec = {
- 'file': 'config_key',
+ 'file': 'keybindingDialog',
'kwds': {'title': 'Test keybindings',
'action': 'find-again',
- 'current_key_sequences': [['<Control-Key-g>', '<Key-F3>', '<Control-Key-G>']],
+ '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 "
- "is invalid.\nNo validity checking if advanced key binding "
+ "is invalid.\nNo validitity checking if advanced key binding "
"entry is used."
}
_grep_dialog_spec = {
- 'file': 'grep',
+ 'file': 'GrepDialog',
'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'->'Go to file/line' anywhere in the search results "
+ "'Right-click'->'Goto file/line' anywhere in the search results "
"should open that file \nin a new EditorWindow."
}
-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"
- "[Ok] or <Return> prints valid entry to shell\n"
- "[Cancel] or <Escape> prints None to shell"
- }
-
_io_binding_spec = {
- 'file': 'iomenu',
+ 'file': 'IOBinding',
'kwds': {},
'msg': "Test the following bindings.\n"
"<Control-o> to open file from dialog.\n"
@@ -206,28 +199,8 @@ _io_binding_spec = {
"Check that changes were saved by opening the file elsewhere."
}
-_linenumbers_drag_scrolling_spec = {
- 'file': 'sidebar',
- 'kwds': {},
- 'msg': textwrap.dedent("""\
- 1. Click on the line numbers and drag down below the edge of the
- window, moving the mouse a bit and then leaving it there for a while.
- The text and line numbers should gradually scroll down, with the
- selection updated continuously.
-
- 2. With the lines still selected, click on a line number above the
- selected lines. Only the line whose number was clicked should be
- selected.
-
- 3. Repeat step #1, dragging to above the window. The text and line
- numbers should gradually scroll up, with the selection updated
- continuously.
-
- 4. Repeat step #2, clicking a line number below the selection."""),
- }
-
_multi_call_spec = {
- 'file': 'multicall',
+ 'file': 'MultiCall',
'kwds': {},
'msg': "The following actions should trigger a print to console or IDLE"
" Shell.\nEntering and leaving the text area, key entry, "
@@ -237,14 +210,14 @@ _multi_call_spec = {
}
_multistatus_bar_spec = {
- 'file': 'statusbar',
+ 'file': 'MultiStatusBar',
'kwds': {},
'msg': "Ensure presence of multi-status bar below text area.\n"
"Click 'Update Status' to change the multi-status text"
}
_object_browser_spec = {
- 'file': 'debugobj',
+ 'file': 'ObjectBrowser',
'kwds': {},
'msg': "Double click on items upto the lowest level.\n"
"Attributes of the objects and related information "
@@ -252,7 +225,7 @@ _object_browser_spec = {
}
_path_browser_spec = {
- 'file': 'pathbrowser',
+ 'file': 'PathBrowser',
'kwds': {},
'msg': "Test for correct display of all paths in sys.path.\n"
"Toggle nested items upto the lowest level.\n"
@@ -261,7 +234,7 @@ _path_browser_spec = {
}
_percolator_spec = {
- 'file': 'percolator',
+ 'file': 'Percolator',
'kwds': {},
'msg': "There are two tracers which can be toggled using a checkbox.\n"
"Toggling a tracer 'on' by checking it should print tracer "
@@ -271,20 +244,8 @@ _percolator_spec = {
"Test for actions like text entry, and removal."
}
-Query_spec = {
- 'file': 'query',
- 'kwds': {'title': 'Query',
- 'message': 'Enter something',
- 'text0': 'Go',
- '_htest': True},
- 'msg': "Enter with <Return> or [Ok]. Print valid entry to Shell\n"
- "Blank line, after stripping, is ignored\n"
- "Close dialog with valid entry, <Escape>, [Cancel], [X]"
- }
-
-
_replace_dialog_spec = {
- 'file': 'replace',
+ 'file': 'ReplaceDialog',
'kwds': {},
'msg': "Click the 'Replace' button.\n"
"Test various replace options in the 'Replace dialog'.\n"
@@ -292,22 +253,15 @@ _replace_dialog_spec = {
}
_search_dialog_spec = {
- 'file': 'search',
+ 'file': 'SearchDialog',
'kwds': {},
'msg': "Click the 'Search' button.\n"
"Test various search options in the 'Search dialog'.\n"
"Click [Close] or [X] to close the 'Search Dialog'."
}
-_searchbase_spec = {
- 'file': 'searchbase',
- 'kwds': {},
- 'msg': "Check the appearance of the base search dialog\n"
- "Its only action is to close."
- }
-
_scrolled_list_spec = {
- 'file': 'scrolledlist',
+ 'file': 'ScrolledList',
'kwds': {},
'msg': "You should see a scrollable list of items\n"
"Selecting (clicking) or double clicking an item "
@@ -323,29 +277,48 @@ show_idlehelp_spec = {
}
_stack_viewer_spec = {
- 'file': 'stackviewer',
+ 'file': 'StackViewer',
'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"
}
+_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"
+ }
+
+TextViewer_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"
+ "Text is selectable. Window is scrollable.",
+ }
+
_tooltip_spec = {
- 'file': 'tooltip',
+ 'file': 'ToolTip',
'kwds': {},
'msg': "Place mouse cursor over both the buttons\n"
"A tooltip should appear with some text."
}
_tree_widget_spec = {
- 'file': 'tree',
+ 'file': 'TreeWidget',
'kwds': {},
'msg': "The canvas is scrollable.\n"
"Click on folders upto to the lowest level."
}
_undo_delegator_spec = {
- 'file': 'undo',
+ 'file': 'UndoDelegator',
'kwds': {},
'msg': "Click [Undo] to undo any action.\n"
"Click [Redo] to redo any action.\n"
@@ -353,17 +326,8 @@ _undo_delegator_spec = {
"by printing to the console or the IDLE shell.\n"
}
-ViewWindow_spec = {
- 'file': 'textview',
- 'kwds': {'title': 'Test textview',
- 'contents': '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"
- }
-
_widget_redirector_spec = {
- 'file': 'redirector',
+ 'file': 'WidgetRedirector',
'kwds': {},
'msg': "Every text insert should be printed to the console "
"or the IDLE shell."
@@ -373,13 +337,14 @@ def run(*tests):
root = tk.Tk()
root.title('IDLE htest')
root.resizable(0, 0)
+ _initializeTkVariantTests(root)
# 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)
- scrollbar = Scrollbar(frameLabel, command=text.yview)
+ scrollbar = tk.Scrollbar(frameLabel, command=text.yview)
text.config(yscrollcommand=scrollbar.set)
scrollbar.pack(side='right', fill='y', expand=False)
text.pack(side='left', fill='both', expand=True)
@@ -400,45 +365,38 @@ def run(*tests):
test = getattr(mod, test_name)
test_list.append((test_spec, test))
- test_name = tk.StringVar(root)
- callable_object = None
- test_kwds = None
+ test_name = [tk.StringVar('')]
+ callable_object = [None]
+ test_kwds = [None]
- def next_test():
- nonlocal test_name, callable_object, test_kwds
+ def next():
if len(test_list) == 1:
next_button.pack_forget()
- test_spec, callable_object = test_list.pop()
- test_kwds = test_spec['kwds']
- test_kwds['parent'] = root
- test_name.set('Test ' + test_spec['name'])
+ test_spec, callable_object[0] = test_list.pop()
+ test_kwds[0] = test_spec['kwds']
+ test_kwds[0]['parent'] = root
+ test_name[0].set('Test ' + test_spec['name'])
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
- def run_test(_=None):
- widget = callable_object(**test_kwds)
+ def run_test():
+ widget = callable_object[0](**test_kwds[0])
try:
print(widget.result)
except AttributeError:
pass
- 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)
+ button = tk.Button(root, textvariable=test_name[0], command=run_test)
button.pack()
+ next_button = tk.Button(root, text="Next", command=next)
next_button.pack()
- next_button.focus_set()
- root.bind('<Key-Return>', run_test)
- root.bind('<Key-Escape>', close)
- next_test()
+ next()
+
root.mainloop()
if __name__ == '__main__':