diff options
| author | Terry Jan Reedy <tjreedy@udel.edu> | 2014-06-04 00:57:15 (GMT) |
|---|---|---|
| committer | Terry Jan Reedy <tjreedy@udel.edu> | 2014-06-04 00:57:15 (GMT) |
| commit | 24330ffb4d9c773b3c5323d4c55b9e2d7bd8b5d0 (patch) | |
| tree | 10f2e6caf2239387ead15fb482b1689f8c52fa18 /Lib/idlelib/idle_test/mock_tk.py | |
| parent | 17f3663497116316116fa560ce59f842cee4e473 (diff) | |
| parent | e3fcfc240d834083ebe05b6ca2faae5988b8477e (diff) | |
| download | cpython-24330ffb4d9c773b3c5323d4c55b9e2d7bd8b5d0.zip cpython-24330ffb4d9c773b3c5323d4c55b9e2d7bd8b5d0.tar.gz cpython-24330ffb4d9c773b3c5323d4c55b9e2d7bd8b5d0.tar.bz2 | |
Merge with 3.4
Diffstat (limited to 'Lib/idlelib/idle_test/mock_tk.py')
| -rw-r--r-- | Lib/idlelib/idle_test/mock_tk.py | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/Lib/idlelib/idle_test/mock_tk.py b/Lib/idlelib/idle_test/mock_tk.py index 762bbc9..b9fd521 100644 --- a/Lib/idlelib/idle_test/mock_tk.py +++ b/Lib/idlelib/idle_test/mock_tk.py @@ -1,9 +1,27 @@ """Classes that replace tkinter gui objects used by an object being tested. -A gui object is anything with a master or parent paramenter, which is typically -required in spite of what the doc strings say. +A gui object is anything with a master or parent paramenter, which is +typically required in spite of what the doc strings say. """ +class Event: + '''Minimal mock with attributes for testing event handlers. + + This is not a gui object, but is used as an argument for callbacks + that access attributes of the event passed. If a callback ignores + the event, other than the fact that is happened, pass 'event'. + + Keyboard, mouse, window, and other sources generate Event instances. + Event instances have the following attributes: serial (number of + event), time (of event), type (of event as number), widget (in which + event occurred), and x,y (position of mouse). There are other + attributes for specific events, such as keycode for key events. + tkinter.Event.__doc__ has more but is still not complete. + ''' + def __init__(self, **kwds): + "Create event with attributes needed for test" + self.__dict__.update(kwds) + class Var: "Use for String/Int/BooleanVar: incomplete" def __init__(self, master=None, value=None, name=None): @@ -20,9 +38,10 @@ class Mbox_func: Instead of displaying a message box, the mock's call method saves the arguments as instance attributes, which test functions can then examime. + The test can set the result returned to ask function """ - def __init__(self): - self.result = None # The return for all show funcs + def __init__(self, result=None): + self.result = result # Return None for all show funcs def __call__(self, title, message, *args, **kwds): # Save all args for possible examination by tester self.title = title |
