Exemple #1
0
def test_groupdisposable_clear():
    disp1 = [False]
    disp2 = [False]

    def action1():
        disp1[0] = True

    d1 = Disposable.create(action1)

    def action2():
        disp2[0] = True

    d2 = Disposable.create(action2)

    g = CompositeDisposable(d1, d2)
    assert g.length == 2

    g.clear()
    assert disp1[0]
    assert disp2[0]
    assert not g.length

    disp3 = [False]

    def action3():
        disp3[0] = True

    d3 = Disposable.create(action3)
    g.add(d3)
    assert not disp3[0]
    assert g.length == 1
Exemple #2
0
def test_groupdisposable_clear():
    disp1 = [False]
    disp2 = [False]
    def action1():
        disp1[0] = True
    d1 = Disposable.create(action1)

    def action2():
        disp2[0] = True
    d2 = Disposable.create(action2)

    g = CompositeDisposable(d1, d2)
    assert g.length == 2

    g.clear()
    assert disp1[0]
    assert disp2[0]
    assert not g.length

    disp3 = [False]
    def action3():
        disp3[0] = True
    d3 = Disposable.create(action3)
    g.add(d3);
    assert not disp3[0]
    assert g.length == 1
def test_groupdisposable_clear():
    disp1 = False
    disp2 = False

    def action1():
        nonlocal disp1
        disp1 = True

    d1 = Disposable(action1)

    def action2():
        nonlocal disp2
        disp2 = True

    d2 = Disposable(action2)

    g = CompositeDisposable(d1, d2)
    assert g.length == 2

    g.clear()
    assert disp1
    assert disp2
    assert not g.length

    disp3 = False

    def action3():
        nonlocal disp3
        disp3 = True

    d3 = Disposable(action3)
    g.add(d3)
    assert not disp3
    assert g.length == 1
def test_groupdisposable_clear():
    disp1 = False
    disp2 = False
    def action1():
        nonlocal disp1
        disp1 = True
    d1 = Disposable(action1)

    def action2():
        nonlocal disp2
        disp2 = True
    d2 = Disposable(action2)

    g = CompositeDisposable(d1, d2)
    assert g.length == 2

    g.clear()
    assert disp1
    assert disp2
    assert not g.length

    disp3 = False
    def action3():
        nonlocal disp3
        disp3 = True
    d3 = Disposable(action3)
    g.add(d3);
    assert not disp3
    assert g.length == 1