Esempio n. 1
0
def M1():
    """
    Helper function that returns a module-like thing with two signals defined
    using :meth:`Signal.define`
    """
    on_foo, on_bar = get_foo_bar()
    ns = NS()
    ns.on_foo_func = on_foo
    ns.on_foo = Signal.define(on_foo)
    ns.on_bar = Signal.define(on_bar)
    return ns
Esempio n. 2
0
def M1():
    """
    Helper function that returns a module-like thing with two signals defined
    using :meth:`Signal.define`
    """
    on_foo, on_bar = get_foo_bar()
    ns = NS()
    ns.on_foo_func = on_foo
    ns.on_foo = Signal.define(on_foo)
    ns.on_bar = Signal.define(on_bar)
    return ns
Esempio n. 3
0
class SignalTestCaseTest(TestCase):
    """
    Test definitions for the :class:`morris.SignalTestCase` class.
    """

    def setUp(self):
        self.signal = Signal('signal')
        self.case = FakeSignalTestCase()

    def test_watchSignal(self):
        """
        Ensure that calling watchSignal() actually connects a signal listener
        """
        self.assertEqual(len(self.signal.listeners), 0)
        self.case.watchSignal(self.signal)
        self.assertEqual(len(self.signal.listeners), 1)

    def test_assertSignalFired(self):
        """
        Ensure that assertSignalFired works correctly
        """
        self.case.watchSignal(self.signal)
        self.signal.fire((), {})
        sig = self.case.assertSignalFired(self.signal)
        self.assertEqual(sig,  (self.signal, (), {}))

    def test_assertSignalNotFired(self):
        """
        Ensure that assertSignalNotFired works correctly
        """
        self.case.watchSignal(self.signal)
        self.case.assertSignalNotFired(self.signal)

    def test_assertSignalOrdering(self):
        """
        Ensure that assertSignalOrdering works correctly
        """
        self.case.watchSignal(self.signal)
        self.signal('first')
        self.signal('second')
        self.signal('third')
        first = self.case.assertSignalFired(self.signal, 'first')
        second = self.case.assertSignalFired(self.signal, 'second')
        third = self.case.assertSignalFired(self.signal, 'third')
        self.case.assertSignalOrdering(first, second, third)
Esempio n. 4
0
class SignalTestCaseTest(TestCase):
    """
    Test definitions for the :class:`morris.SignalTestCase` class.
    """
    def setUp(self):
        self.signal = Signal('signal')
        self.case = FakeSignalTestCase()

    def test_watchSignal(self):
        """
        Ensure that calling watchSignal() actually connects a signal listener
        """
        self.assertEqual(len(self.signal.listeners), 0)
        self.case.watchSignal(self.signal)
        self.assertEqual(len(self.signal.listeners), 1)

    def test_assertSignalFired(self):
        """
        Ensure that assertSignalFired works correctly
        """
        self.case.watchSignal(self.signal)
        self.signal.fire((), {})
        sig = self.case.assertSignalFired(self.signal)
        self.assertEqual(sig, (self.signal, (), {}))

    def test_assertSignalNotFired(self):
        """
        Ensure that assertSignalNotFired works correctly
        """
        self.case.watchSignal(self.signal)
        self.case.assertSignalNotFired(self.signal)

    def test_assertSignalOrdering(self):
        """
        Ensure that assertSignalOrdering works correctly
        """
        self.case.watchSignal(self.signal)
        self.signal('first')
        self.signal('second')
        self.signal('third')
        first = self.case.assertSignalFired(self.signal, 'first')
        second = self.case.assertSignalFired(self.signal, 'second')
        third = self.case.assertSignalFired(self.signal, 'third')
        self.case.assertSignalOrdering(first, second, third)
Esempio n. 5
0
class C1(object):
    """
    Helper class with two signals defined using :meth:`Signal.define`
    """
    def on_foo(self, *args, **kwargs):
        """
        A signal accepting (ignoring) arbitrary arguments
        """

    on_foo_func = on_foo
    on_foo = Signal.define(on_foo)

    @Signal.define
    def on_bar(self):
        """
Esempio n. 6
0
 def setUp(self):
     self.signal = Signal('signal')
     self.case = FakeSignalTestCase()
Esempio n. 7
0
 def setUp(self):
     self.signal = Signal('signal')
     self.case = FakeSignalTestCase()