| 
									
										
										
										
											2023-12-01 02:02:31 -05:00
										 |  |  | """Run human tests of Idle's window, dialog, and popup widgets.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | run(*tests) Create a master Tk() htest 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 master window to end testing. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | In a tested module, let X be a global name bound to a callable (class or | 
					
						
							|  |  |  | function) whose .__name__ attribute is also X (the usual situation). The | 
					
						
							| 
									
										
										
										
											2023-12-03 04:28:37 -05:00
										 |  |  | first parameter of X must be 'parent' or 'master'.  When called, the | 
					
						
							|  |  |  | first argument will be the root window.  X must create a child | 
					
						
							|  |  |  | Toplevel(parent/master) (or subclass thereof).  The Toplevel may be a | 
					
						
							|  |  |  | test widget or dialog, in which case the callable is the corresponding | 
					
						
							|  |  |  | 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 '_' and be lowercase. | 
					
						
							| 
									
										
										
										
											2014-10-17 01:31:35 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-15 20:50:10 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-01 00:30:34 -04:00
										 |  |  | End the module with | 
					
						
							| 
									
										
										
										
											2014-05-11 23:32:32 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | if __name__ == '__main__': | 
					
						
							| 
									
										
										
										
											2023-12-01 02:02:31 -05:00
										 |  |  |     <run unittest.main with 'exit=False'> | 
					
						
							| 
									
										
										
										
											2014-05-11 23:32:32 -04:00
										 |  |  |     from idlelib.idle_test.htest import run | 
					
						
							| 
									
										
										
										
											2023-12-01 02:02:31 -05:00
										 |  |  |     run(callable)  # There could be multiple comma-separated callables. | 
					
						
							| 
									
										
										
										
											2014-05-11 23:32:32 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-01 02:02:31 -05:00
										 |  |  | To have wrapper functions ignored by coverage reports, tag the def | 
					
						
							|  |  |  | header like so: "def _wrapper(parent):  # htest #".  Use the same tag | 
					
						
							|  |  |  | for htest lines in widget code.  Make sure that the 'if __name__' line | 
					
						
							|  |  |  | matches the above.  Then have make sure that .coveragerc includes the | 
					
						
							|  |  |  | following: | 
					
						
							| 
									
										
										
										
											2014-10-17 01:31:35 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | [report] | 
					
						
							|  |  |  | exclude_lines = | 
					
						
							|  |  |  |     .*# htest # | 
					
						
							|  |  |  |     if __name__ == .__main__.: | 
					
						
							| 
									
										
										
										
											2014-05-15 20:50:10 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-17 01:31:35 -04:00
										 |  |  | (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. | 
					
						
							| 
									
										
										
										
											2014-05-15 20:50:10 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-01 02:02:31 -05:00
										 |  |  | callable_spec = { | 
					
						
							| 
									
										
										
										
											2014-05-11 23:32:32 -04:00
										 |  |  |     'file': '', | 
					
						
							|  |  |  |     'kwds': {'title': ''}, | 
					
						
							|  |  |  |     'msg': "" | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-05-15 20:50:10 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-17 01:31:35 -04:00
										 |  |  | file (no .py): run() imports file.py. | 
					
						
							|  |  |  | kwds: augmented with {'parent':root} and passed to X as **kwds. | 
					
						
							| 
									
										
										
										
											2023-12-01 02:02:31 -05:00
										 |  |  | title: an example kwd; some widgets need this, delete line if not. | 
					
						
							| 
									
										
										
										
											2014-10-17 01:31:35 -04:00
										 |  |  | msg: master window hints about testing the widget. | 
					
						
							| 
									
										
										
										
											2014-06-01 00:30:34 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-17 01:31:35 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-01 02:02:31 -05:00
										 |  |  | TODO test these modules and classes: | 
					
						
							|  |  |  |   autocomplete_w.AutoCompleteWindow | 
					
						
							|  |  |  |   debugger.Debugger | 
					
						
							|  |  |  |   outwin.OutputWindow (indirectly being tested with grep test) | 
					
						
							|  |  |  |   pyshell.PyShellEditorWindow | 
					
						
							|  |  |  | """
 | 
					
						
							| 
									
										
										
										
											2014-10-17 01:31:35 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-27 00:07:30 -04:00
										 |  |  | import idlelib.pyshell  # Set Windows DPI awareness before Tk(). | 
					
						
							| 
									
										
										
										
											2014-05-11 23:32:32 -04:00
										 |  |  | from importlib import import_module | 
					
						
							| 
									
										
										
										
											2019-07-23 15:22:11 +03:00
										 |  |  | import textwrap | 
					
						
							| 
									
										
										
										
											2014-05-11 23:32:32 -04:00
										 |  |  | import tkinter as tk | 
					
						
							| 
									
										
										
										
											2016-06-10 18:19:21 -04:00
										 |  |  | from tkinter.ttk import Scrollbar | 
					
						
							| 
									
										
										
										
											2016-06-21 18:41:38 -04:00
										 |  |  | tk.NoDefaultRoot() | 
					
						
							| 
									
										
										
										
											2014-05-11 23:32:32 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | AboutDialog_spec = { | 
					
						
							| 
									
										
										
										
											2016-05-28 13:22:31 -04:00
										 |  |  |     'file': 'help_about', | 
					
						
							|  |  |  |     'kwds': {'title': 'help_about test', | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |              '_htest': True, | 
					
						
							|  |  |  |              }, | 
					
						
							| 
									
										
										
										
											2022-02-01 20:20:23 -05:00
										 |  |  |     'msg': "Click on URL to open in default browser.\n" | 
					
						
							|  |  |  |            "Verify x.y.z versions and test each button, including Close.\n " | 
					
						
							| 
									
										
										
										
											2014-06-01 00:30:34 -04:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-05 09:21:08 +03:00
										 |  |  | # TODO implement ^\; adding '<Control-Key-\\>' to function does not work. | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  | _calltip_window_spec = { | 
					
						
							| 
									
										
										
										
											2016-05-28 13:22:31 -04:00
										 |  |  |     'file': 'calltip_w', | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     'kwds': {}, | 
					
						
							|  |  |  |     'msg': "Typing '(' should display a calltip.\n" | 
					
						
							|  |  |  |            "Typing ') should hide the calltip.\n" | 
					
						
							| 
									
										
										
										
											2018-08-05 09:21:08 +03:00
										 |  |  |            "So should moving cursor out of argument area.\n" | 
					
						
							|  |  |  |            "Force-open-calltip does not work here.\n" | 
					
						
							| 
									
										
										
										
											2014-05-11 23:32:32 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  | _color_delegator_spec = { | 
					
						
							| 
									
										
										
										
											2016-05-28 13:22:31 -04:00
										 |  |  |     'file': 'colorizer', | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     'kwds': {}, | 
					
						
							|  |  |  |     'msg': "The text is sample Python code.\n" | 
					
						
							|  |  |  |            "Ensure components like comments, keywords, builtins,\n" | 
					
						
							|  |  |  |            "string, definitions, and break are correctly colored.\n" | 
					
						
							|  |  |  |            "The default color scheme is in idlelib/config-highlight.def" | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-29 01:46:26 -04:00
										 |  |  | ConfigDialog_spec = { | 
					
						
							| 
									
										
										
										
											2016-05-28 13:22:31 -04:00
										 |  |  |     'file': 'configdialog', | 
					
						
							| 
									
										
										
										
											2014-10-17 01:31:35 -04:00
										 |  |  |     'kwds': {'title': 'ConfigDialogTest', | 
					
						
							| 
									
										
										
										
											2014-05-29 01:46:26 -04:00
										 |  |  |              '_htest': True,}, | 
					
						
							|  |  |  |     'msg': "IDLE preferences dialog.\n" | 
					
						
							|  |  |  |            "In the 'Fonts/Tabs' tab, changing font face, should update the " | 
					
						
							|  |  |  |            "font face of the text in the area below it.\nIn the " | 
					
						
							|  |  |  |            "'Highlighting' tab, try different color schemes. Clicking " | 
					
						
							|  |  |  |            "items in the sample program should update the choices above it." | 
					
						
							| 
									
										
										
										
											2018-11-05 16:20:25 +02:00
										 |  |  |            "\nIn the 'Keys', 'General' and 'Extensions' tabs, test settings " | 
					
						
							| 
									
										
										
										
											2015-10-13 22:03:51 -04:00
										 |  |  |            "of interest." | 
					
						
							| 
									
										
										
										
											2014-05-29 01:46:26 -04:00
										 |  |  |            "\n[Ok] to close the dialog.[Apply] to apply the settings and " | 
					
						
							|  |  |  |            "and [Cancel] to revert all changes.\nRe-run the test to ensure " | 
					
						
							|  |  |  |            "changes made have persisted." | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-01 02:02:31 -05:00
										 |  |  | CustomRun_spec = { | 
					
						
							|  |  |  |     'file': 'query', | 
					
						
							|  |  |  |     'kwds': {'title': 'Customize query.py Run', | 
					
						
							|  |  |  |              '_htest': True}, | 
					
						
							| 
									
										
										
										
											2023-12-03 04:28:37 -05:00
										 |  |  |     'msg': "Enter with <Return> or [OK].  Print valid entry to Shell\n" | 
					
						
							| 
									
										
										
										
											2023-12-01 02:02:31 -05:00
										 |  |  |            "Arguments are parsed into a list\n" | 
					
						
							|  |  |  |            "Mode is currently restart True or False\n" | 
					
						
							|  |  |  |            "Close dialog with valid entry, <Escape>, [Cancel], [X]" | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-03 04:28:37 -05:00
										 |  |  | _debug_object_browser_spec = { | 
					
						
							|  |  |  |     'file': 'debugobj', | 
					
						
							|  |  |  |     'kwds': {}, | 
					
						
							|  |  |  |     'msg': "Double click on items up to the lowest level.\n" | 
					
						
							|  |  |  |            "Attributes of the objects and related information " | 
					
						
							|  |  |  |            "will be displayed side-by-side at each level." | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-17 01:31:35 -04:00
										 |  |  | # TODO Improve message | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  | _dyn_option_menu_spec = { | 
					
						
							| 
									
										
										
										
											2016-05-28 13:22:31 -04:00
										 |  |  |     'file': 'dynoption', | 
					
						
							| 
									
										
										
										
											2014-05-19 00:12:10 -04:00
										 |  |  |     'kwds': {}, | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     'msg': "Select one of the many options in the 'old option set'.\n" | 
					
						
							|  |  |  |            "Click the button to change the option set.\n" | 
					
						
							|  |  |  |            "Select one of the many options in the 'new option set'." | 
					
						
							| 
									
										
										
										
											2014-05-19 00:12:10 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-17 01:31:35 -04:00
										 |  |  | # TODO edit wrapper | 
					
						
							| 
									
										
										
										
											2014-05-25 18:44:05 -04:00
										 |  |  | _editor_window_spec = { | 
					
						
							| 
									
										
										
										
											2016-05-28 13:22:31 -04:00
										 |  |  |    'file': 'editor', | 
					
						
							| 
									
										
										
										
											2014-05-25 18:44:05 -04:00
										 |  |  |     'kwds': {}, | 
					
						
							| 
									
										
										
										
											2014-10-17 01:31:35 -04:00
										 |  |  |     'msg': "Test editor functions of interest.\n" | 
					
						
							|  |  |  |            "Best to close editor first." | 
					
						
							| 
									
										
										
										
											2014-05-25 18:44:05 -04:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-30 02:08:44 -05:00
										 |  |  | GetKeysWindow_spec = { | 
					
						
							| 
									
										
										
										
											2016-05-28 13:22:31 -04:00
										 |  |  |     'file': 'config_key', | 
					
						
							| 
									
										
										
										
											2014-05-25 18:44:05 -04:00
										 |  |  |     'kwds': {'title': 'Test keybindings', | 
					
						
							|  |  |  |              'action': 'find-again', | 
					
						
							| 
									
										
										
										
											2018-12-27 22:47:54 -05:00
										 |  |  |              'current_key_sequences': [['<Control-Key-g>', '<Key-F3>', '<Control-Key-G>']], | 
					
						
							| 
									
										
										
										
											2014-05-25 18:44:05 -04:00
										 |  |  |              '_htest': True, | 
					
						
							|  |  |  |              }, | 
					
						
							|  |  |  |     'msg': "Test for different key modifier sequences.\n" | 
					
						
							|  |  |  |            "<nothing> is invalid.\n" | 
					
						
							|  |  |  |            "No modifier key is invalid.\n" | 
					
						
							| 
									
										
										
										
											2018-11-05 16:20:25 +02:00
										 |  |  |            "Shift key with [a-z],[0-9], function key, move key, tab, space " | 
					
						
							| 
									
										
										
										
											2014-10-19 18:04:38 +03:00
										 |  |  |            "is invalid.\nNo validity checking if advanced key binding " | 
					
						
							| 
									
										
										
										
											2014-05-25 18:44:05 -04:00
										 |  |  |            "entry is used." | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-29 01:46:26 -04:00
										 |  |  | _grep_dialog_spec = { | 
					
						
							| 
									
										
										
										
											2016-05-28 13:22:31 -04:00
										 |  |  |     'file': 'grep', | 
					
						
							| 
									
										
										
										
											2014-05-29 01:46:26 -04:00
										 |  |  |     'kwds': {}, | 
					
						
							|  |  |  |     'msg': "Click the 'Show GrepDialog' button.\n" | 
					
						
							|  |  |  |            "Test the various 'Find-in-files' functions.\n" | 
					
						
							|  |  |  |            "The results should be displayed in a new '*Output*' window.\n" | 
					
						
							| 
									
										
										
										
											2023-12-04 01:36:40 -05:00
										 |  |  |            "'Right-click'->'Go to file/line' in the search results\n " | 
					
						
							|  |  |  |            "should open that file in a new EditorWindow." | 
					
						
							| 
									
										
										
										
											2014-05-29 01:46:26 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-08 00:22:50 -04:00
										 |  |  | 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" | 
					
						
							| 
									
										
										
										
											2016-07-25 20:58:43 -04:00
										 |  |  |            "[Ok] or <Return> prints valid entry to shell\n" | 
					
						
							| 
									
										
										
										
											2023-12-03 04:28:37 -05:00
										 |  |  |            "<Escape>, [Cancel], or [X] prints None to shell" | 
					
						
							| 
									
										
										
										
											2016-07-08 00:22:50 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  | _io_binding_spec = { | 
					
						
							| 
									
										
										
										
											2016-05-28 13:22:31 -04:00
										 |  |  |     'file': 'iomenu', | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     'kwds': {}, | 
					
						
							| 
									
										
										
										
											2015-10-30 02:47:06 -04:00
										 |  |  |     'msg': "Test the following bindings.\n" | 
					
						
							|  |  |  |            "<Control-o> to open file from dialog.\n" | 
					
						
							|  |  |  |            "Edit the file.\n" | 
					
						
							| 
									
										
										
										
											2016-01-27 11:51:50 -05:00
										 |  |  |            "<Control-p> to print the file.\n" | 
					
						
							| 
									
										
										
										
											2015-10-30 02:47:06 -04:00
										 |  |  |            "<Control-s> to save the file.\n" | 
					
						
							| 
									
										
										
										
											2016-01-27 11:51:50 -05:00
										 |  |  |            "<Alt-s> to save-as another file.\n" | 
					
						
							|  |  |  |            "<Control-c> to save-copy-as another file.\n" | 
					
						
							| 
									
										
										
										
											2015-10-30 02:47:06 -04:00
										 |  |  |            "Check that changes were saved by opening the file elsewhere." | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | _multi_call_spec = { | 
					
						
							| 
									
										
										
										
											2016-05-28 13:22:31 -04:00
										 |  |  |     'file': 'multicall', | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     'kwds': {}, | 
					
						
							| 
									
										
										
										
											2023-12-03 04:28:37 -05:00
										 |  |  |     'msg': "The following should trigger a print to console or IDLE Shell.\n" | 
					
						
							|  |  |  |            "Entering and leaving the text area, key entry, <Control-Key>,\n" | 
					
						
							|  |  |  |            "<Alt-Key-a>, <Control-Key-a>, <Alt-Control-Key-a>, \n" | 
					
						
							|  |  |  |            "<Control-Button-1>, <Alt-Button-1> and focusing elsewhere." | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-01 02:02:31 -05:00
										 |  |  | _module_browser_spec = { | 
					
						
							|  |  |  |     'file': 'browser', | 
					
						
							|  |  |  |     'kwds': {}, | 
					
						
							| 
									
										
										
										
											2023-12-03 04:28:37 -05:00
										 |  |  |     'msg': textwrap.dedent("""
 | 
					
						
							|  |  |  |         "Inspect names of module, class(with superclass if applicable), | 
					
						
							|  |  |  |         "methods and functions.  Toggle nested items.  Double clicking | 
					
						
							|  |  |  |         "on items prints a traceback for an exception that is ignored.""") | 
					
						
							| 
									
										
										
										
											2023-12-01 02:02:31 -05:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  | _multistatus_bar_spec = { | 
					
						
							| 
									
										
										
										
											2016-05-28 13:22:31 -04:00
										 |  |  |     'file': 'statusbar', | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     'kwds': {}, | 
					
						
							|  |  |  |     'msg': "Ensure presence of multi-status bar below text area.\n" | 
					
						
							| 
									
										
										
										
											2023-12-03 04:28:37 -05:00
										 |  |  |            "Click 'Update Status' to change the status text" | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-03 04:28:37 -05:00
										 |  |  | PathBrowser_spec = { | 
					
						
							| 
									
										
										
										
											2016-05-28 13:22:31 -04:00
										 |  |  |     'file': 'pathbrowser', | 
					
						
							| 
									
										
										
										
											2023-12-03 04:28:37 -05:00
										 |  |  |     'kwds': {'_htest': True}, | 
					
						
							| 
									
										
										
										
											2014-05-25 18:44:05 -04:00
										 |  |  |     'msg': "Test for correct display of all paths in sys.path.\n" | 
					
						
							| 
									
										
										
										
											2023-12-03 04:28:37 -05:00
										 |  |  |            "Toggle nested items out to the lowest level.\n" | 
					
						
							| 
									
										
										
										
											2014-05-25 18:44:05 -04:00
										 |  |  |            "Double clicking on an item prints a traceback\n" | 
					
						
							|  |  |  |            "for an exception that is ignored." | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | _percolator_spec = { | 
					
						
							| 
									
										
										
										
											2016-05-28 13:22:31 -04:00
										 |  |  |     'file': 'percolator', | 
					
						
							| 
									
										
										
										
											2014-05-25 18:44:05 -04:00
										 |  |  |     'kwds': {}, | 
					
						
							|  |  |  |     'msg': "There are two tracers which can be toggled using a checkbox.\n" | 
					
						
							| 
									
										
										
										
											2018-11-05 16:20:25 +02:00
										 |  |  |            "Toggling a tracer 'on' by checking it should print tracer " | 
					
						
							| 
									
										
										
										
											2014-05-25 18:44:05 -04:00
										 |  |  |            "output to the console or to the IDLE shell.\n" | 
					
						
							|  |  |  |            "If both the tracers are 'on', the output from the tracer which " | 
					
						
							|  |  |  |            "was switched 'on' later, should be printed first\n" | 
					
						
							|  |  |  |            "Test for actions like text entry, and removal." | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-26 22:05:10 -04:00
										 |  |  | Query_spec = { | 
					
						
							|  |  |  |     'file': 'query', | 
					
						
							| 
									
										
										
										
											2016-07-03 19:11:13 -04:00
										 |  |  |     'kwds': {'title': 'Query', | 
					
						
							|  |  |  |              'message': 'Enter something', | 
					
						
							|  |  |  |              'text0': 'Go', | 
					
						
							| 
									
										
										
										
											2016-06-26 22:05:10 -04:00
										 |  |  |              '_htest': True}, | 
					
						
							|  |  |  |     'msg': "Enter with <Return> or [Ok].  Print valid entry to Shell\n" | 
					
						
							|  |  |  |            "Blank line, after stripping, is ignored\n" | 
					
						
							| 
									
										
										
										
											2016-07-25 20:58:43 -04:00
										 |  |  |            "Close dialog with valid entry, <Escape>, [Cancel], [X]" | 
					
						
							| 
									
										
										
										
											2016-06-26 22:05:10 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-27 03:30:54 -04:00
										 |  |  | _replace_dialog_spec = { | 
					
						
							| 
									
										
										
										
											2016-05-28 13:22:31 -04:00
										 |  |  |     'file': 'replace', | 
					
						
							| 
									
										
										
										
											2014-05-27 03:30:54 -04:00
										 |  |  |     'kwds': {}, | 
					
						
							|  |  |  |     'msg': "Click the 'Replace' button.\n" | 
					
						
							|  |  |  |            "Test various replace options in the 'Replace dialog'.\n" | 
					
						
							| 
									
										
										
										
											2014-06-01 00:30:34 -04:00
										 |  |  |            "Click [Close] or [X] to close the 'Replace Dialog'." | 
					
						
							| 
									
										
										
										
											2014-05-27 03:30:54 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-04 01:36:40 -05:00
										 |  |  | _scrolled_list_spec = { | 
					
						
							|  |  |  |     'file': 'scrolledlist', | 
					
						
							|  |  |  |     'kwds': {}, | 
					
						
							|  |  |  |     'msg': "You should see a scrollable list of items\n" | 
					
						
							|  |  |  |            "Selecting (clicking) or double clicking an item " | 
					
						
							|  |  |  |            "prints the name to the console or Idle shell.\n" | 
					
						
							|  |  |  |            "Right clicking an item will display a popup." | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-27 03:30:54 -04:00
										 |  |  | _search_dialog_spec = { | 
					
						
							| 
									
										
										
										
											2016-05-28 13:22:31 -04:00
										 |  |  |     'file': 'search', | 
					
						
							| 
									
										
										
										
											2014-05-27 03:30:54 -04:00
										 |  |  |     'kwds': {}, | 
					
						
							|  |  |  |     'msg': "Click the 'Search' button.\n" | 
					
						
							|  |  |  |            "Test various search options in the 'Search dialog'.\n" | 
					
						
							| 
									
										
										
										
											2014-06-01 00:30:34 -04:00
										 |  |  |            "Click [Close] or [X] to close the 'Search Dialog'." | 
					
						
							| 
									
										
										
										
											2014-05-27 03:30:54 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-10 20:21:31 -04:00
										 |  |  | _searchbase_spec = { | 
					
						
							|  |  |  |     'file': 'searchbase', | 
					
						
							|  |  |  |     'kwds': {}, | 
					
						
							|  |  |  |     'msg': "Check the appearance of the base search dialog\n" | 
					
						
							|  |  |  |            "Its only action is to close." | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-06 07:23:26 +01:00
										 |  |  | show_idlehelp_spec = { | 
					
						
							|  |  |  |     'file': 'help', | 
					
						
							|  |  |  |     'kwds': {}, | 
					
						
							|  |  |  |     'msg': "If the help text displays, this works.\n" | 
					
						
							|  |  |  |            "Text is selectable. Window is scrollable." | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-04 01:36:40 -05:00
										 |  |  | _sidebar_number_scrolling_spec = { | 
					
						
							|  |  |  |     'file': 'sidebar', | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     'kwds': {}, | 
					
						
							| 
									
										
										
										
											2023-12-04 01:36:40 -05:00
										 |  |  |     'msg': textwrap.dedent("""\
 | 
					
						
							|  |  |  |         1. Click on the line numbers and drag down below the edge of the | 
					
						
							|  |  |  |         window, moving the mouse a bit and then leaving it there for a | 
					
						
							|  |  |  |         while. The text and line numbers should gradually scroll down, | 
					
						
							|  |  |  |         with the selection updated continuously. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         2. With the lines still selected, click on a line number above | 
					
						
							|  |  |  |         or below the selected lines. Only the line whose number was | 
					
						
							|  |  |  |         clicked should be selected. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         3. Repeat step #1, dragging to above the window. The text and | 
					
						
							|  |  |  |         line numbers should gradually scroll up, with the selection | 
					
						
							|  |  |  |         updated continuously. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         4. Repeat step #2, clicking a line number below the selection."""), | 
					
						
							| 
									
										
										
										
											2014-05-25 18:44:05 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-03 23:45:56 -05:00
										 |  |  | _stackbrowser_spec = { | 
					
						
							| 
									
										
										
										
											2016-05-28 13:22:31 -04:00
										 |  |  |     'file': 'stackviewer', | 
					
						
							| 
									
										
										
										
											2014-05-25 18:44:05 -04:00
										 |  |  |     'kwds': {}, | 
					
						
							|  |  |  |     'msg': "A stacktrace for a NameError exception.\n" | 
					
						
							| 
									
										
										
										
											2023-12-04 01:36:40 -05:00
										 |  |  |            "Should have NameError and 1 traceback line." | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | _tooltip_spec = { | 
					
						
							| 
									
										
										
										
											2016-05-28 13:22:31 -04:00
										 |  |  |     'file': 'tooltip', | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     'kwds': {}, | 
					
						
							|  |  |  |     'msg': "Place mouse cursor over both the buttons\n" | 
					
						
							|  |  |  |            "A tooltip should appear with some text." | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | _tree_widget_spec = { | 
					
						
							| 
									
										
										
										
											2016-05-28 13:22:31 -04:00
										 |  |  |     'file': 'tree', | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     'kwds': {}, | 
					
						
							| 
									
										
										
										
											2014-05-27 03:30:54 -04:00
										 |  |  |     'msg': "The canvas is scrollable.\n" | 
					
						
							| 
									
										
										
										
											2021-10-07 01:13:48 +02:00
										 |  |  |            "Click on folders up to to the lowest level." | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-29 01:46:26 -04:00
										 |  |  | _undo_delegator_spec = { | 
					
						
							| 
									
										
										
										
											2016-05-28 13:22:31 -04:00
										 |  |  |     'file': 'undo', | 
					
						
							| 
									
										
										
										
											2014-05-29 01:46:26 -04:00
										 |  |  |     'kwds': {}, | 
					
						
							|  |  |  |     'msg': "Click [Undo] to undo any action.\n" | 
					
						
							|  |  |  |            "Click [Redo] to redo any action.\n" | 
					
						
							|  |  |  |            "Click [Dump] to dump the current state " | 
					
						
							|  |  |  |            "by printing to the console or the IDLE shell.\n" | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-29 18:42:17 -04:00
										 |  |  | ViewWindow_spec = { | 
					
						
							|  |  |  |     'file': 'textview', | 
					
						
							|  |  |  |     'kwds': {'title': 'Test textview', | 
					
						
							| 
									
										
										
										
											2019-07-27 19:57:48 +03:00
										 |  |  |              'contents': 'The quick brown fox jumps over the lazy dog.\n'*35, | 
					
						
							| 
									
										
										
										
											2017-06-29 18:42:17 -04:00
										 |  |  |              '_htest': True}, | 
					
						
							|  |  |  |     'msg': "Test for read-only property of text.\n" | 
					
						
							|  |  |  |            "Select text, scroll window, close" | 
					
						
							|  |  |  |      } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  | _widget_redirector_spec = { | 
					
						
							| 
									
										
										
										
											2016-05-28 13:22:31 -04:00
										 |  |  |     'file': 'redirector', | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     'kwds': {}, | 
					
						
							| 
									
										
										
										
											2018-11-05 16:20:25 +02:00
										 |  |  |     'msg': "Every text insert should be printed to the console " | 
					
						
							| 
									
										
										
										
											2014-05-25 18:44:05 -04:00
										 |  |  |            "or the IDLE shell." | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-25 18:44:05 -04:00
										 |  |  | def run(*tests): | 
					
						
							| 
									
										
										
										
											2023-12-03 04:28:37 -05:00
										 |  |  |     "Run callables in tests." | 
					
						
							| 
									
										
										
										
											2014-05-11 23:32:32 -04:00
										 |  |  |     root = tk.Tk() | 
					
						
							| 
									
										
										
										
											2014-05-29 01:46:26 -04:00
										 |  |  |     root.title('IDLE htest') | 
					
						
							|  |  |  |     root.resizable(0, 0) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-03 04:28:37 -05:00
										 |  |  |     # A scrollable Label-like constant width text widget. | 
					
						
							| 
									
										
										
										
											2014-05-29 01:46:26 -04:00
										 |  |  |     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) | 
					
						
							| 
									
										
										
										
											2016-06-10 18:19:21 -04:00
										 |  |  |     scrollbar = Scrollbar(frameLabel, command=text.yview) | 
					
						
							| 
									
										
										
										
											2014-05-29 01:46:26 -04:00
										 |  |  |     text.config(yscrollcommand=scrollbar.set) | 
					
						
							|  |  |  |     scrollbar.pack(side='right', fill='y', expand=False) | 
					
						
							|  |  |  |     text.pack(side='left', fill='both', expand=True) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-03 04:28:37 -05:00
										 |  |  |     test_list = [] # Make list of (spec, callable) tuples. | 
					
						
							| 
									
										
										
										
											2014-05-25 18:44:05 -04:00
										 |  |  |     if tests: | 
					
						
							|  |  |  |         for test in tests: | 
					
						
							|  |  |  |             test_spec = globals()[test.__name__ + '_spec'] | 
					
						
							|  |  |  |             test_spec['name'] = test.__name__ | 
					
						
							|  |  |  |             test_list.append((test_spec,  test)) | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     else: | 
					
						
							| 
									
										
										
										
											2023-12-03 04:28:37 -05:00
										 |  |  |         for key, dic in globals().items(): | 
					
						
							|  |  |  |             if key.endswith('_spec'): | 
					
						
							|  |  |  |                 test_name = key[:-5] | 
					
						
							|  |  |  |                 test_spec = dic | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |                 test_spec['name'] = test_name | 
					
						
							|  |  |  |                 mod = import_module('idlelib.' + test_spec['file']) | 
					
						
							|  |  |  |                 test = getattr(mod, test_name) | 
					
						
							| 
									
										
										
										
											2014-05-25 18:44:05 -04:00
										 |  |  |                 test_list.append((test_spec, test)) | 
					
						
							| 
									
										
										
										
											2023-12-03 04:28:37 -05:00
										 |  |  |     test_list.reverse()  # So can pop in proper order in next_test. | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-21 18:41:38 -04:00
										 |  |  |     test_name = tk.StringVar(root) | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     callable_object = None | 
					
						
							|  |  |  |     test_kwds = None | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-27 22:17:05 -04:00
										 |  |  |     def next_test(): | 
					
						
							| 
									
										
										
										
											2014-05-29 01:46:26 -04:00
										 |  |  |         nonlocal test_name, callable_object, test_kwds | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |         if len(test_list) == 1: | 
					
						
							|  |  |  |             next_button.pack_forget() | 
					
						
							| 
									
										
										
										
											2014-05-25 18:44:05 -04:00
										 |  |  |         test_spec, callable_object = test_list.pop() | 
					
						
							|  |  |  |         test_kwds = test_spec['kwds'] | 
					
						
							|  |  |  |         test_name.set('Test ' + test_spec['name']) | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-03 04:28:37 -05:00
										 |  |  |         text['state'] = 'normal'  # Enable text replacement. | 
					
						
							|  |  |  |         text.delete('1.0', 'end') | 
					
						
							|  |  |  |         text.insert("1.0", test_spec['msg']) | 
					
						
							|  |  |  |         text['state'] = 'disabled'  # Restore read-only property. | 
					
						
							| 
									
										
										
										
											2014-05-15 20:50:10 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-27 22:17:05 -04:00
										 |  |  |     def run_test(_=None): | 
					
						
							| 
									
										
										
										
											2023-12-03 04:28:37 -05:00
										 |  |  |         widget = callable_object(root, **test_kwds) | 
					
						
							| 
									
										
										
										
											2014-05-11 23:32:32 -04:00
										 |  |  |         try: | 
					
						
							| 
									
										
										
										
											2023-12-03 04:28:37 -05:00
										 |  |  |             print(widget.result)  # Only true for query classes(?). | 
					
						
							| 
									
										
										
										
											2014-05-11 23:32:32 -04:00
										 |  |  |         except AttributeError: | 
					
						
							|  |  |  |             pass | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-27 22:17:05 -04:00
										 |  |  |     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) | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     button.pack() | 
					
						
							|  |  |  |     next_button.pack() | 
					
						
							| 
									
										
										
										
											2016-07-27 22:17:05 -04:00
										 |  |  |     next_button.focus_set() | 
					
						
							|  |  |  |     root.bind('<Key-Return>', run_test) | 
					
						
							|  |  |  |     root.bind('<Key-Escape>', close) | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-27 22:17:05 -04:00
										 |  |  |     next_test() | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     root.mainloop() | 
					
						
							| 
									
										
										
										
											2014-05-11 23:32:32 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-04 01:36:40 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-11 23:32:32 -04:00
										 |  |  | if __name__ == '__main__': | 
					
						
							| 
									
										
										
										
											2014-05-24 18:48:18 -04:00
										 |  |  |     run() |