Exemple #1
0
def test_simple_chaining(sig):
    signal2 = Signal()
    sig.connect(lambda: 1, weak=False)
    sig.connect(lambda: 2, weak=False)
    sig.connect(lambda: 3, weak=False)
    signal2.connect(lambda: 4, weak=False)
    signal2.connect(lambda: 5, weak=False)
    signal2.connect(lambda: 6, weak=False)
    sig.connect(signal2)
    assert sorted(sig()) == [1, 2, 3, 4, 5, 6]
Exemple #2
0
def test_lazy_connect(collector):
    s1 = Signal()
    s2 = Signal()
    s3 = Signal()

    s1.connect(s2)
    s2.connect(s3)

    assert not s1
    assert not s2
    assert not s3

    s3.connect(collector.collect)

    assert s1
    assert s2
    assert s3

    s1(3)
    collector.check(3)
Exemple #3
0
def test_chaining_with_lists(sig):
    signal2 = Signal()
    sig.connect(lambda: [1, 2], weak=False)
    signal2.connect(lambda: [3, 4], weak=False)
    sig.connect(signal2)
    assert sorted(sig()) == [[1, 2], [3, 4]]