summaryrefslogtreecommitdiff
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.py145
1 files changed, 81 insertions, 64 deletions
diff --git a/Lib/idlelib/idle_test/htest.py b/Lib/idlelib/idle_test/htest.py
index 58e62cb4e2..6f676ae865 100644
--- a/Lib/idlelib/idle_test/htest.py
+++ b/Lib/idlelib/idle_test/htest.py
@@ -59,19 +59,20 @@ msg: master window hints about testing the widget.
Modules and classes not being tested at the moment:
-PyShell.PyShellEditorWindow
-Debugger.Debugger
-AutoCompleteWindow.AutoCompleteWindow
-OutputWindow.OutputWindow (indirectly being tested with grep test)
+pyshell.PyShellEditorWindow
+debugger.Debugger
+autocomplete_w.AutoCompleteWindow
+outwin.OutputWindow (indirectly being tested with grep test)
'''
from importlib import import_module
-from idlelib.macosxSupport import _initializeTkVariantTests
import tkinter as tk
+from tkinter.ttk import Scrollbar
+tk.NoDefaultRoot()
AboutDialog_spec = {
- 'file': 'aboutDialog',
- 'kwds': {'title': 'aboutDialog test',
+ 'file': 'help_about',
+ 'kwds': {'title': 'help_about test',
'_htest': True,
},
'msg': "Test every button. Ensure Python, TK and IDLE versions "
@@ -79,14 +80,14 @@ AboutDialog_spec = {
}
_calltip_window_spec = {
- 'file': 'CallTipWindow',
+ 'file': 'calltip_w',
'kwds': {},
'msg': "Typing '(' should display a calltip.\n"
"Typing ') should hide the calltip.\n"
}
_class_browser_spec = {
- 'file': 'ClassBrowser',
+ 'file': 'browser',
'kwds': {},
'msg': "Inspect names of module, class(with superclass if "
"applicable), methods and functions.\nToggle nested items.\n"
@@ -95,7 +96,7 @@ _class_browser_spec = {
}
_color_delegator_spec = {
- 'file': 'ColorDelegator',
+ 'file': 'colorizer',
'kwds': {},
'msg': "The text is sample Python code.\n"
"Ensure components like comments, keywords, builtins,\n"
@@ -104,7 +105,7 @@ _color_delegator_spec = {
}
ConfigDialog_spec = {
- 'file': 'configDialog',
+ 'file': 'configdialog',
'kwds': {'title': 'ConfigDialogTest',
'_htest': True,},
'msg': "IDLE preferences dialog.\n"
@@ -121,7 +122,7 @@ ConfigDialog_spec = {
# TODO Improve message
_dyn_option_menu_spec = {
- 'file': 'dynOptionMenuWidget',
+ 'file': 'dynoption',
'kwds': {},
'msg': "Select one of the many options in the 'old option set'.\n"
"Click the button to change the option set.\n"
@@ -130,39 +131,15 @@ _dyn_option_menu_spec = {
# TODO edit wrapper
_editor_window_spec = {
- 'file': 'EditorWindow',
+ 'file': 'editor',
'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': 'keybindingDialog',
+ 'file': 'config_key',
'kwds': {'title': 'Test keybindings',
'action': 'find-again',
'currentKeySequences': [''] ,
@@ -177,7 +154,7 @@ GetKeysDialog_spec = {
}
_grep_dialog_spec = {
- 'file': 'GrepDialog',
+ 'file': 'grep',
'kwds': {},
'msg': "Click the 'Show GrepDialog' button.\n"
"Test the various 'Find-in-files' functions.\n"
@@ -186,8 +163,24 @@ _grep_dialog_spec = {
"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': 'IOBinding',
+ 'file': 'iomenu',
'kwds': {},
'msg': "Test the following bindings.\n"
"<Control-o> to open file from dialog.\n"
@@ -200,7 +193,7 @@ _io_binding_spec = {
}
_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, "
@@ -210,14 +203,14 @@ _multi_call_spec = {
}
_multistatus_bar_spec = {
- 'file': 'MultiStatusBar',
+ 'file': 'statusbar',
'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': 'ObjectBrowser',
+ 'file': 'debugobj',
'kwds': {},
'msg': "Double click on items upto the lowest level.\n"
"Attributes of the objects and related information "
@@ -225,7 +218,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"
@@ -234,7 +227,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"
@@ -244,8 +237,20 @@ _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': 'ReplaceDialog',
+ 'file': 'replace',
'kwds': {},
'msg': "Click the 'Replace' button.\n"
"Test various replace options in the 'Replace dialog'.\n"
@@ -253,15 +258,22 @@ _replace_dialog_spec = {
}
_search_dialog_spec = {
- 'file': 'SearchDialog',
+ 'file': 'search',
'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 "
@@ -277,7 +289,7 @@ show_idlehelp_spec = {
}
_stack_viewer_spec = {
- 'file': 'StackViewer',
+ 'file': 'stackviewer',
'kwds': {},
'msg': "A stacktrace for a NameError exception.\n"
"Expand 'idlelib ...' and '<locals>'.\n"
@@ -295,8 +307,8 @@ _tabbed_pages_spec = {
}
TextViewer_spec = {
- 'file': 'textView',
- 'kwds': {'title': 'Test textView',
+ '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"
@@ -304,21 +316,21 @@ TextViewer_spec = {
}
_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': 'TreeWidget',
+ 'file': 'tree',
'kwds': {},
'msg': "The canvas is scrollable.\n"
"Click on folders upto to the lowest level."
}
_undo_delegator_spec = {
- 'file': 'UndoDelegator',
+ 'file': 'undo',
'kwds': {},
'msg': "Click [Undo] to undo any action.\n"
"Click [Redo] to redo any action.\n"
@@ -327,7 +339,7 @@ _undo_delegator_spec = {
}
_widget_redirector_spec = {
- 'file': 'WidgetRedirector',
+ 'file': 'redirector',
'kwds': {},
'msg': "Every text insert should be printed to the console."
"or the IDLE shell."
@@ -337,14 +349,13 @@ 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 = tk.Scrollbar(frameLabel, command=text.yview)
+ scrollbar = 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)
@@ -365,11 +376,11 @@ def run(*tests):
test = getattr(mod, test_name)
test_list.append((test_spec, test))
- test_name = tk.StringVar('')
+ test_name = tk.StringVar(root)
callable_object = None
test_kwds = None
- def next():
+ def next_test():
nonlocal test_name, callable_object, test_kwds
if len(test_list) == 1:
@@ -384,20 +395,26 @@ def run(*tests):
text.insert("1.0",test_spec['msg'])
text.configure(state='disabled') # preserve read-only property
- def run_test():
+ def run_test(_=None):
widget = callable_object(**test_kwds)
try:
print(widget.result)
except AttributeError:
pass
- button = tk.Button(root, textvariable=test_name, command=run_test)
+ 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.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()
-
+ next_test()
root.mainloop()
if __name__ == '__main__':