From 06313b79d5c0eaeed8f37838b5e9a064eecf0b98 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Sun, 11 May 2014 23:32:32 -0400 Subject: 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. --- Lib/idlelib/EditorWindow.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'Lib/idlelib/EditorWindow.py') diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py index cdb67750f3..06fb137d93 100644 --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -79,6 +79,8 @@ class HelpDialog(object): self.parent = None helpDialog = HelpDialog() # singleton instance +def _Help_dialog(parent): # wrapper for htest + helpDialog.show_dialog(parent) class EditorWindow(object): @@ -1064,7 +1066,7 @@ class EditorWindow(object): try: try: mod = importlib.import_module('.' + name, package=__package__) - except ImportError: + except (ImportError, TypeError): mod = importlib.import_module(name) except ImportError: print("\nFailed to import extension: ", name) @@ -1700,19 +1702,21 @@ def fixwordbreaks(root): tk.call('set', 'tcl_nonwordchars', '[^a-zA-Z0-9_]') -def test(): - root = Tk() +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) - root.mainloop() - root.destroy() if __name__ == '__main__': - test() + from idlelib.idle_test.htest import run + if len(sys.argv) <= 1: + run(_Help_dialog) + run(_Editor_window) -- cgit v1.2.1