Generic mock for messagebox functions, which all have the same signature. Instead of displaying a message box, the mock's call method saves the arguments as instance attributes, which test functions can then examine. The test can set the result returned to ask function
| 39 | |
| 40 | |
| 41 | class Mbox_func: |
| 42 | """Generic mock for messagebox functions, which all have the same signature. |
| 43 | |
| 44 | Instead of displaying a message box, the mock's call method saves the |
| 45 | arguments as instance attributes, which test functions can then examine. |
| 46 | The test can set the result returned to ask function |
| 47 | """ |
| 48 | def __init__(self, result=None): |
| 49 | self.result = result # Return None for all show funcs |
| 50 | def __call__(self, title, message, *args, **kwds): |
| 51 | # Save all args for possible examination by tester |
| 52 | self.title = title |
| 53 | self.message = message |
| 54 | self.args = args |
| 55 | self.kwds = kwds |
| 56 | return self.result # Set by tester for ask functions |
| 57 | |
| 58 | |
| 59 | class Mbox: |
no outgoing calls
searching dependent graphs…