diff options
Diffstat (limited to 'Lib/idlelib/idle_test/mock_idle.py')
-rw-r--r-- | Lib/idlelib/idle_test/mock_idle.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/idlelib/idle_test/mock_idle.py b/Lib/idlelib/idle_test/mock_idle.py index 8f3147b..f279a52 100644 --- a/Lib/idlelib/idle_test/mock_idle.py +++ b/Lib/idlelib/idle_test/mock_idle.py @@ -13,14 +13,16 @@ class Func: self.args - capture positional arguments. self.kwds - capture keyword arguments. self.result - return or raise value set in __init__. + self.return_self - return self instead, to mock query class return. Most common use will probably be to mock instance methods. Given class instance, can set and delete as instance attribute. Mock_tk.Var and Mbox_func are special variants of this. ''' - def __init__(self, result=None): + def __init__(self, result=None, return_self=False): self.called = 0 self.result = result + self.return_self = return_self self.args = None self.kwds = None def __call__(self, *args, **kwds): @@ -29,6 +31,8 @@ class Func: self.kwds = kwds if isinstance(self.result, BaseException): raise self.result + elif self.return_self: + return self else: return self.result |