Issue #18104: Add idlelib/idle_test/htest.py with a few sample tests to begin
consolidating and improving human-validated tests of Idle. Change other files
as needed to work with htest. Running the module as __main__ runs all tests.
diff --git a/Lib/idlelib/configSectionNameDialog.py b/Lib/idlelib/configSectionNameDialog.py
index 04fcd8c..c09dca8 100644
--- a/Lib/idlelib/configSectionNameDialog.py
+++ b/Lib/idlelib/configSectionNameDialog.py
@@ -7,10 +7,11 @@
from Tkinter import *
import tkMessageBox
class GetCfgSectionNameDialog(Toplevel):
- def __init__(self, parent, title, message, used_names):
+ def __init__(self, parent, title, message, used_names, _htest=False):
"""
message - string, informational message to display
used_names - string collection, names already in use for validity check
+ _htest - bool, change box location when running htest
"""
Toplevel.__init__(self, parent)
self.configure(borderwidth=5)
@@ -29,11 +30,12 @@
self.messageInfo.config(width=self.frameMain.winfo_reqwidth())
self.geometry(
"+%d+%d" % (
- parent.winfo_rootx() +
- (parent.winfo_width()/2 - self.winfo_reqwidth()/2),
- parent.winfo_rooty() +
- (parent.winfo_height()/2 - self.winfo_reqheight()/2)
- ) ) #centre dialog over parent
+ parent.winfo_rootx() +
+ (parent.winfo_width()/2 - self.winfo_reqwidth()/2),
+ parent.winfo_rooty() +
+ ((parent.winfo_height()/2 - self.winfo_reqheight()/2)
+ if not _htest else 100)
+ ) ) #centre dialog over parent (or below htest box)
self.deiconify() #geometry set, unhide
self.wait_window()
def create_widgets(self):
@@ -86,15 +88,5 @@
import unittest
unittest.main('idlelib.idle_test.test_config_name', verbosity=2, exit=False)
- # also human test the dialog
- root = Tk()
- def run():
- dlg=GetCfgSectionNameDialog(root,'Get Name',
- "After the text entered with [Ok] is stripped, <nothing>, "
- "'abc', or more that 30 chars are errors. "
- "Close with a valid entry (printed), [Cancel], or [X]",
- {'abc'})
- print dlg.result
- Message(root, text='').pack() # will be needed for oher dialog tests
- Button(root, text='Click to begin dialog test', command=run).pack()
- root.mainloop()
+ from idlelib.idle_test.htest import run
+ run(GetCfgSectionNameDialog)