cpython: 72a8a107eed1 (original) (raw)
Mercurial > cpython
changeset 90867:72a8a107eed1 2.7
Issue #21477: Idle htest: modify run; add more tests. Patch by Saimadhav Heblikar. 2.7 backport of 90829, d7eea8f608c2. [#21477]
Terry Jan Reedy tjreedy@udel.edu | |
---|---|
date | Tue, 27 May 2014 02:47:38 -0400 |
parents | be77b213ace0 |
children | e770d8c4291c |
files | Lib/idlelib/ClassBrowser.py Lib/idlelib/ColorDelegator.py Lib/idlelib/EditorWindow.py Lib/idlelib/PathBrowser.py Lib/idlelib/Percolator.py Lib/idlelib/StackViewer.py Lib/idlelib/ToolTip.py Lib/idlelib/idle_test/htest.py Lib/idlelib/keybindingDialog.py |
diffstat | 9 files changed, 158 insertions(+), 96 deletions(-)[+] [-] Lib/idlelib/ClassBrowser.py 2 Lib/idlelib/ColorDelegator.py 8 Lib/idlelib/EditorWindow.py 10 Lib/idlelib/PathBrowser.py 2 Lib/idlelib/Percolator.py 50 Lib/idlelib/StackViewer.py 39 Lib/idlelib/ToolTip.py 5 Lib/idlelib/idle_test/htest.py 112 Lib/idlelib/keybindingDialog.py 26 |
line wrap: on
line diff
--- a/Lib/idlelib/ClassBrowser.py +++ b/Lib/idlelib/ClassBrowser.py @@ -13,7 +13,6 @@ XXX TO DO: import os import sys import pyclbr -import re from idlelib import PyShell from idlelib.WindowList import ListedToplevel @@ -223,6 +222,7 @@ def _class_browser(parent): #Wrapper for name = os.path.splitext(file)[0] flist = PyShell.PyShellFileList(parent) ClassBrowser(flist, name, [dir], _htest=True)
if name == "main": from idlelib.idle_test.htest import run
--- a/Lib/idlelib/ColorDelegator.py +++ b/Lib/idlelib/ColorDelegator.py @@ -261,13 +261,9 @@ def _color_delegator(parent): root.title("Test ColorDelegator") width, height, x, y = list(map(int, re.split('[x+]', parent.geometry()))) root.geometry("+%d+%d"%(x, y + 150)) -## with open(file, 'r') as f: -## source = f.read()
-## text.insert("insert", source[:690])
- text.insert("insert", source) text.pack(expand=1, fill="both") p = Percolator(text) d = ColorDelegator()
--- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -1714,18 +1714,16 @@ def fixwordbreaks(root): def _editor_window(parent): root = parent fixwordbreaks(root) -## root.withdraw() if sys.argv[1:]: filename = sys.argv[1] else: filename = None macosxSupport.setupApp(root, None) edit = EditorWindow(root=root, filename=filename) -## edit.set_close_hook(root.quit) -## edit.text.bind("<>", edit.close_event)
+ if name == 'main': from idlelib.idle_test.htest import run
--- a/Lib/idlelib/PathBrowser.py +++ b/Lib/idlelib/PathBrowser.py @@ -1,6 +1,5 @@ import os import sys -import re import imp from idlelib.TreeWidget import TreeItem @@ -95,6 +94,7 @@ class DirBrowserTreeItem(TreeItem): def _path_browser(parent): flist = PyShellFileList(parent) PathBrowser(flist, _htest=True)
if name == "main": from unittest import main
--- a/Lib/idlelib/Percolator.py +++ b/Lib/idlelib/Percolator.py @@ -52,7 +52,9 @@ class Percolator: filter.setdelegate(None) -def main(): +def _percolator(parent):
@@ -63,23 +65,39 @@ def main(): def delete(self, *args): print self.name, ": delete", args self.delegate.delete(*args)
- root = Tk()
- root.wm_protocol("WM_DELETE_WINDOW", root.quit)
- text = Text()
- text.pack()
- text.focus_set()
- root = tk.Tk()
- root.title("Test Percolator")
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 150))
- text = tk.Text(root) p = Percolator(text) t1 = Tracer("t1") t2 = Tracer("t2")
- p.insertfilter(t1)
- p.insertfilter(t2)
- root.mainloop()
- p.removefilter(t2)
- root.mainloop()
- p.insertfilter(t2)
- p.removefilter(t1)
- root.mainloop()
- def toggle1():
if var1.get() == 0:[](#l5.41)
var1.set(1)[](#l5.42)
p.insertfilter(t1)[](#l5.43)
elif var1.get() == 1:[](#l5.44)
var1.set(0)[](#l5.45)
p.removefilter(t1)[](#l5.46)
- def toggle2():
if var2.get() == 0:[](#l5.49)
var2.set(1)[](#l5.50)
p.insertfilter(t2)[](#l5.51)
elif var2.get() == 1:[](#l5.52)
var2.set(0)[](#l5.53)
p.removefilter(t2)[](#l5.54)
- text.pack()
- var1 = tk.IntVar()
- cb1 = tk.Checkbutton(root, text="Tracer1", command=toggle1, variable=var1)
- cb1.pack()
- var2 = tk.IntVar()
- cb2 = tk.Checkbutton(root, text="Tracer2", command=toggle2, variable=var2)
- cb2.pack()
--- a/Lib/idlelib/StackViewer.py +++ b/Lib/idlelib/StackViewer.py @@ -1,9 +1,12 @@ import os import sys import linecache +import re +import Tkinter as tk from idlelib.TreeWidget import TreeNode, TreeItem, ScrolledCanvas from idlelib.ObjectBrowser import ObjectTreeItem, make_objecttreeitem +from idlelib.PyShell import PyShellFileList def StackBrowser(root, flist=None, tb=None, top=None): if top is None: @@ -121,17 +124,29 @@ class VariablesTreeItem(ObjectTreeItem): sublist.append(item) return sublist - -def _test():
- root = tk.Tk()
- root.title("Test StackViewer")
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 150))
- flist = PyShellFileList(root)
- try: # to obtain a traceback object
except:a[](#l6.32)
sys.last_type, sys.last_value, sys.last_traceback = sys.exc_info()[](#l6.34)
- from Tkinter import Tk
- root = Tk()
- StackBrowser(None, top=root)
- root.mainloop()
exc_type, exc_value, exc_tb = sys.exc_info()[](#l6.39)
inject stack trace to sys
- sys.last_type = exc_type
- sys.last_value = exc_value
- sys.last_traceback = exc_tb
--- a/Lib/idlelib/ToolTip.py +++ b/Lib/idlelib/ToolTip.py @@ -87,8 +87,9 @@ def _tooltip(parent): button2 = Button(root, text="Button 2") button1.pack() button2.pack()
- ToolTip(button1, "This is calltip text for button1.")
- ListboxToolTip(button2, ["This is","calltip text","for button2"])
- ToolTip(button1, "This is tooltip text for button1.")
- ListboxToolTip(button2, ["This is","multiple line",
root.mainloop() if name == 'main':"tooltip text","for button2"])[](#l7.11)
--- a/Lib/idlelib/idle_test/htest.py +++ b/Lib/idlelib/idle_test/htest.py @@ -40,7 +40,7 @@ AboutDialog_spec = { }, 'msg': "Test every button. Ensure Python, TK and IDLE versions " "are correctly displayed.\n [Close] to exit.",
}[](#l8.7)
_calltip_window_spec = { 'file': 'CallTipWindow', @@ -53,9 +53,10 @@ AboutDialog_spec = { 'file': 'ClassBrowser', 'kwds': {}, 'msg': "Inspect names of module, class(with superclass if "
"applicable), methods and functions.\nToggle nested items."[](#l8.16)
"\nN.S: Double click on items does not work",[](#l8.17)
}[](#l8.18)
"applicable), methods and functions.\nToggle nested items.\n"[](#l8.19)
"Double clicking on items prints a traceback for an exception "[](#l8.20)
"that is ignored."[](#l8.21)
- }
_color_delegator_spec = { 'file': 'ColorDelegator', @@ -74,11 +75,11 @@ AboutDialog_spec = { "Select one of the many options in the 'new option set'." } -#_editor_window_spec = { -# 'file': 'EditorWindow', -# 'kwds': {}, -# 'msg': "Test editor functions of interest" -# } +_editor_window_spec = {
GetCfgSectionNameDialog_spec = { 'file': 'configSectionNameDialog', @@ -91,6 +92,7 @@ GetCfgSectionNameDialog_spec = { "Close 'Get Name' with a valid entry (printed to Shell), " "[Cancel], or [X]", } + GetHelpSourceDialog_spec = { 'file': 'configHelpSourceEdit', 'kwds': {'title': 'Get helpsource', @@ -103,10 +105,27 @@ GetHelpSourceDialog_spec = { "[Cancel] will print None to shell", } +# Update once issue21519 is resolved. +GetKeysDialog_spec = {
- 'file': 'keybindingDialog',
- 'kwds': {'title': 'Test keybindings',
'action': 'find-again',[](#l8.59)
'currentKeySequences': [''] ,[](#l8.60)
'_htest': True,[](#l8.61)
},[](#l8.62)
- 'msg': "Test for different key modifier sequences.\n"
"<nothing> is invalid.\n"[](#l8.64)
"No modifier key is invalid.\n"[](#l8.65)
"Shift key with [a-z],[0-9], function key, move key, tab, space"[](#l8.66)
"is invalid.\nNo validitity checking if advanced key binding "[](#l8.67)
"entry is used."[](#l8.68)
- }
+ _help_dialog_spec = { 'file': 'EditorWindow', 'kwds': {},
- 'msg': "If the help text displays, this works.\n"
} _io_binding_spec = { @@ -115,17 +134,16 @@ GetHelpSourceDialog_spec = { 'msg': "Test the following bindings\n" " to display open window from file dialog.\n" " to save the file\n""Text is selectable. Window is scrollable."[](#l8.76)
- } _multi_call_spec = { 'file': 'MultiCall', 'kwds': {},
- 'msg': "The following actions should trigger a print to console.\n"
"Entering and leaving the text area, key entry, <Control-Key>,\n"[](#l8.91)
"<Alt-Key-a>, <Control-Key-a>, <Alt-Control-Key-a>, \n"[](#l8.92)
"<Control-Button-1>, <Alt-Button-1> and focussing out of the window\n"[](#l8.93)
"are sequences to be tested."[](#l8.94)
- 'msg': "The following actions should trigger a print to console or IDLE"
" Shell.\nEntering and leaving the text area, key entry, "[](#l8.96)
"<Control-Key>,\n<Alt-Key-a>, <Control-Key-a>, "[](#l8.97)
"<Alt-Control-Key-a>, \n<Control-Button-1>, <Alt-Button-1> and "[](#l8.98)
} _multistatus_bar_spec = { @@ -146,18 +164,38 @@ GetHelpSourceDialog_spec = { _path_browser_spec = { 'file': 'PathBrowser', 'kwds': {},"focusing out of the window\nare sequences to be tested."[](#l8.99)
- 'msg': "Test for correct display of all paths in sys.path."
"\nToggle nested items upto the lowest level."[](#l8.108)
"\nN.S: Double click on items does not work."[](#l8.109)
- 'msg': "Test for correct display of all paths in sys.path.\n"
"Toggle nested items upto the lowest level.\n"[](#l8.111)
"Double clicking on an item prints a traceback\n"[](#l8.112)
"for an exception that is ignored."[](#l8.113)
- }
- '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"[](#l8.120)
"output to the console or to the IDLE shell.\n"[](#l8.121)
"If both the tracers are 'on', the output from the tracer which "[](#l8.122)
"was switched 'on' later, should be printed first\n"[](#l8.123)
} _scrolled_list_spec = { 'file': 'ScrolledList', 'kwds': {}, 'msg': "You should see a scrollable list of items\n""Test for actions like text entry, and removal."[](#l8.124)
"Selecting an item will print it to console.\n"[](#l8.131)
"Double clicking an item will print it to console\n"[](#l8.132)
"Right click on an item will display a popup."[](#l8.133)
"Selecting (clicking) or double clicking an item "[](#l8.134)
"prints the name to the console or Idle shell.\n"[](#l8.135)
"Right clicking an item will display a popup."[](#l8.136)
- }
- 'file': 'StackViewer',
- 'kwds': {},
- 'msg': "A stacktrace for a NameError exception.\n"
"Expand 'idlelib ...' and '<locals>'.\n"[](#l8.143)
} _tabbed_pages_spec = { @@ -189,7 +227,7 @@ TextViewer_spec = { _tree_widget_spec = { 'file': 'TreeWidget', 'kwds': {},"Check that exc_value, exc_tb, and exc_type are correct.\n"[](#l8.144)
- 'msg': "You should see two canvases side-by-side.\n" "The left canvas is scrollable.\n" "The right canvas is not scrollable.\n" "Click on folders upto to the lowest level."
@@ -198,29 +236,27 @@ TextViewer_spec = { _widget_redirector_spec = { 'file': 'WidgetRedirector', 'kwds': {},
- 'msg': "Every text insert should be printed to the console."
} -def run(test=None): +def run(*tests): root = tk.Tk()"or the IDLE shell."[](#l8.163)
- test_list = [] # List of tuples of the form (spec, kwds, callable widget)
- if test:
test_spec = globals()[test.__name__ + '_spec'][](#l8.171)
test_spec['name'] = test.__name__[](#l8.172)
test_kwds = test_spec['kwds'][](#l8.173)
test_kwds['parent'] = root[](#l8.174)
test_list.append((test_spec, test_kwds, test))[](#l8.175)
- test_list = [] # List of tuples of the form (spec, callable widget)
- if tests:
for test in tests:[](#l8.178)
test_spec = globals()[test.__name__ + '_spec'][](#l8.179)
test_spec['name'] = test.__name__[](#l8.180)
else: for k, d in globals().items(): if k.endswith('_spec'): test_name = k[:-5] test_spec = d test_spec['name'] = test_nametest_list.append((test_spec, test))[](#l8.181)
test_kwds = test_spec['kwds'][](#l8.188)
test_kwds['parent'] = root[](#l8.189) mod = import_module('idlelib.' + test_spec['file'])[](#l8.190) test = getattr(mod, test_name)[](#l8.191)
test_list.append((test_spec, test_kwds, test))[](#l8.192)
test_list.append((test_spec, test))[](#l8.193)
help_string = [tk.StringVar('')] test_name = [tk.StringVar('')] @@ -231,11 +267,11 @@ def run(test=None): def next(): if len(test_list) == 1: next_button.pack_forget()
test_spec, test_kwds[0], test = test_list.pop()[](#l8.201)
test_spec, callable_object[0] = test_list.pop()[](#l8.202)
test_kwds[0] = test_spec['kwds'][](#l8.203)
test_kwds[0]['parent'] = root[](#l8.204) help_string[0].set(test_spec['msg'])[](#l8.205) test_name[0].set('test ' + test_spec['name'])[](#l8.206)
callable_object[0] = test[](#l8.207)
- def run_test(): widget = callable_object0
--- a/Lib/idlelib/keybindingDialog.py +++ b/Lib/idlelib/keybindingDialog.py @@ -7,12 +7,13 @@ import string import sys class GetKeysDialog(Toplevel):
- def init(self,parent,title,action,currentKeySequences,_htest=False): """ action - string, the name of the virtual event these keys will be mapped to currentKeys - list, a list of all key sequence lists currently mapped to virtual events, for overlap checking
_htest - bool, change box location when running htest[](#l9.14) """[](#l9.15) Toplevel.__init__(self, parent)[](#l9.16) self.configure(borderwidth=5)[](#l9.17)
@@ -38,11 +39,14 @@ class GetKeysDialog(Toplevel): self.LoadFinalKeyList() self.withdraw() #hide while setting geometry self.update_idletasks()
self.geometry("+%d+%d" %[](#l9.22)
((parent.winfo_rootx()+((parent.winfo_width()/2)[](#l9.23)
-(self.winfo_reqwidth()/2)),[](#l9.24)
parent.winfo_rooty()+((parent.winfo_height()/2)[](#l9.25)
-(self.winfo_reqheight()/2)) )) ) #centre dialog over parent[](#l9.26)
self.geometry([](#l9.27)
"+%d+%d" % ([](#l9.28)
parent.winfo_rootx() +[](#l9.29)
(parent.winfo_width()/2 - self.winfo_reqwidth()/2),[](#l9.30)
parent.winfo_rooty() +[](#l9.31)
((parent.winfo_height()/2 - self.winfo_reqheight()/2)[](#l9.32)
if not _htest else 150)[](#l9.33)
) ) #centre dialog over parent (or below htest box)[](#l9.34) self.deiconify() #geometry set, unhide[](#l9.35) self.wait_window()[](#l9.36)
@@ -258,11 +262,5 @@ class GetKeysDialog(Toplevel): return keysOK if name == 'main':