From 18af0b4b3556c88c7e7fc3ea417b66f9ce5aca75 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 2 Sep 2015 20:40:19 +0200 Subject: [PATCH] tests: Make FakeSignal callable. --- tests/helpers/stubs.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/helpers/stubs.py b/tests/helpers/stubs.py index 53d97e0a0..f99ffad5f 100644 --- a/tests/helpers/stubs.py +++ b/tests/helpers/stubs.py @@ -206,10 +206,22 @@ def fake_qprocess(): class FakeSignal: - """Fake pyqtSignal stub which does nothing.""" + """Fake pyqtSignal stub which does nothing. - def __init__(self, name='fake'): + Attributes: + signal: The name of the signal, like pyqtSignal. + _func: The function to be invoked when the signal gets called. + """ + + def __init__(self, name='fake', func=None): self.signal = '2{}(int, int)'.format(name) + self._func = func + + def __call__(self): + if self._func is None: + raise TypeError("'FakeSignal' object is not callable") + else: + return self._func() def connect(self, slot): """Connect the signal to a slot.