Exemple #1
0
def test_groupdisposable_remove():
    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
    assert g.contains(d1)
    assert g.contains(d2)
    assert g.remove(d1)
    assert g.length == 1
    assert not g.contains(d1)
    assert g.contains(d2)
    assert disp1[0]
    assert g.remove(d2)
    assert not g.contains(d1)
    assert not g.contains(d2)
    assert disp2[0]

    disp3 = [False]

    def action3():
        disp3[0] = True
    d3 = Disposable.create(action3)
    assert not g.remove(d3)
    assert not disp3[0]
def test_groupdisposable_remove():
    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
    assert g.contains(d1)
    assert g.contains(d2)
    assert g.remove(d1)
    assert g.length == 1
    assert not g.contains(d1)
    assert g.contains(d2)
    assert disp1
    assert g.remove(d2)
    assert not g.contains(d1)
    assert not g.contains(d2)
    assert disp2

    disp3 = False

    def action3():
        nonlocal disp3
        disp3 = True

    d3 = Disposable(action3)
    assert not g.remove(d3)
    assert not disp3
Exemple #3
0
def test_groupdisposable_remove():
    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
    assert g.contains(d1)
    assert g.contains(d2)
    assert g.remove(d1)
    assert g.length == 1
    assert not g.contains(d1)
    assert g.contains(d2)
    assert disp1[0]
    assert g.remove(d2)
    assert not g.contains(d1)
    assert not g.contains(d2)
    assert disp2[0]

    disp3 = [False]

    def action3():
        disp3[0] = True

    d3 = Disposable.create(action3)
    assert not g.remove(d3)
    assert not disp3[0]
def test_groupdisposable_remove():
    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
    assert g.contains(d1)
    assert g.contains(d2)
    assert g.remove(d1)
    assert g.length == 1
    assert not g.contains(d1)
    assert g.contains(d2)
    assert disp1
    assert g.remove(d2)
    assert not g.contains(d1)
    assert not g.contains(d2)
    assert disp2

    disp3 = False;

    def action3():
        nonlocal disp3
        disp3 = True
    d3 = Disposable(action3)
    assert not g.remove(d3)
    assert not disp3