diff -r f4e291263a6d Lib/idlelib/CallTipWindow.py --- a/Lib/idlelib/CallTipWindow.py Mon Oct 13 15:50:37 2014 -0400 +++ b/Lib/idlelib/CallTipWindow.py Mon Oct 13 21:27:52 2014 -0400 @@ -133,37 +133,30 @@ def _calltip_window(parent): # htest # - import re - from tkinter import Tk, Text, LEFT, BOTH + from tkinter import Toplevel, Text, LEFT, BOTH - root = Tk() + root = Toplevel(parent) root.title("Test calltips") - width, height, x, y = list(map(int, re.split('[x+]', parent.geometry()))) - root.geometry("+%d+%d"%(x, y + 150)) + root.geometry("200x100+%d+%d" % (parent.winfo_rootx() + 200, + parent.winfo_rooty() + 150)) - class MyEditWin: # conceptually an editor_window - def __init__(self): - text = self.text = Text(root) - text.pack(side=LEFT, fill=BOTH, expand=1) - text.insert("insert", "string.split") - root.update() - self.calltip = CallTip(text) + text = Text(root) + text.pack(side=LEFT, fill=BOTH, expand=1) + text.insert("insert", "string.split") + root.update() + calltip = CallTip(text) - text.event_add("<>", "(") - text.event_add("<>", ")") - text.bind("<>", self.calltip_show) - text.bind("<>", self.calltip_hide) + def calltip_show(event): + calltip.showtip("(s=Hello world)", "insert", "end") - text.focus_set() - root.mainloop() + def calltip_hide(event): + calltip.hidetip() + text.event_add("<>", "(") + text.event_add("<>", ")") + text.bind("<>", calltip_show) + text.bind("<>", calltip_hide) - def calltip_show(self, event): - self.calltip.showtip("Hello world", "insert", "end") - - def calltip_hide(self, event): - self.calltip.hidetip() - - MyEditWin() + text.focus_set() if __name__=='__main__': from idlelib.idle_test.htest import run diff -r f4e291263a6d Lib/idlelib/configDialog.py --- a/Lib/idlelib/configDialog.py Mon Oct 13 15:50:37 2014 -0400 +++ b/Lib/idlelib/configDialog.py Mon Oct 13 21:27:52 2014 -0400 @@ -24,7 +24,7 @@ class ConfigDialog(Toplevel): - def __init__(self, parent, title, _htest=False, _utest=False): + def __init__(self, parent, title='', _htest=False, _utest=False): """ _htest - bool, change box location when running htest _utest - bool, don't wait_window when running unittest @@ -36,7 +36,7 @@ self.wm_withdraw() self.configure(borderwidth=5) - self.title('IDLE Preferences') + self.title(title or 'IDLE Preferences') self.geometry( "+%d+%d" % (parent.winfo_rootx() + 20, parent.winfo_rooty() + (30 if not _htest else 150))) diff -r f4e291263a6d Lib/idlelib/idle_test/htest.py --- a/Lib/idlelib/idle_test/htest.py Mon Oct 13 15:50:37 2014 -0400 +++ b/Lib/idlelib/idle_test/htest.py Mon Oct 13 21:27:52 2014 -0400 @@ -1,11 +1,24 @@ '''Run human tests of Idle's window, dialog, and popup widgets. run(*tests) -Run each callable in tests after finding the matching test spec in this file. -If there are none, run an htest for each spec dict in this file after finding -the matching callable in the module named in the spec. +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 widget callable. +In a tested module, let X be a global name bound to a callable (class +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 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 '_'. + + End the module with if __name__ == '__main__': @@ -13,13 +26,25 @@ from idlelib.idle_test.htest import run run(X) -The X object must have a .__name__ attribute and a 'parent' parameter. -X will often be a widget class, but a callable instance with .__name__ -or a wrapper function also work. The name of wrapper functions, like -'_editor_window', should start with '_'. +To have wrapper functions and test invocation code ignored by coveragepy +reports, put '# htest #' on the def statement header line. -This file must contain a matching instance of the following template, -with X.__name__ prepended, as in '_editor_window_spec ...'. +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__.: + +(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. _spec = { 'file': '', @@ -27,18 +52,19 @@ 'msg': "" } -file (no .py): used in run() to import the file and get X. -kwds: passed to X (**kwds), after 'parent' is added, to initialize X. -title: an example; used for some widgets, delete if not. -msg: displayed in a master window. Hints as to how the user might - test the widget. Close the window to skip or end the test. +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. -Modules not being tested at the moment: + +Modules and classes not being tested at the moment: PyShell.PyShellEditorWindow Debugger.Debugger AutoCompleteWindow.AutoCompleteWindow OutputWindow.OutputWindow (indirectly being tested with grep test) ''' + from importlib import import_module from idlelib.macosxSupport import _initializeTkVariantTests import tkinter as tk @@ -79,7 +105,7 @@ ConfigDialog_spec = { 'file': 'configDialog', - 'kwds': {'title': 'Settings', + 'kwds': {'title': 'ConfigDialogTest', '_htest': True,}, 'msg': "IDLE preferences dialog.\n" "In the 'Fonts/Tabs' tab, changing font face, should update the "