def test_currentthread_ensuretrampoline_nested(self):
        scheduler = CurrentThreadScheduler()
        ran1, ran2 = [False], [False]

        def outer_action(scheduler, state):
            def inner_action1(scheduler, state):
                ran1[0] = True

            scheduler.ensure_trampoline(inner_action1)

            def inner_action2(scheduler, state):
                ran2[0] = True

            return scheduler.ensure_trampoline(inner_action2)

        scheduler.ensure_trampoline(outer_action)
        assert ran1[0] == True
        assert ran2[0] == True
 def test_currentthread_ensuretrampoline_nested(self):
     scheduler = CurrentThreadScheduler()
     ran1, ran2 = [False], [False]
 
     def outer_action(scheduler, state):
         def inner_action1(scheduler, state):
             ran1[0] = True
         
         scheduler.ensure_trampoline(inner_action1)
         
         def inner_action2(scheduler, state):
             ran2[0] = True
         
         return scheduler.ensure_trampoline(inner_action2)
 
     scheduler.ensure_trampoline(outer_action)
     assert ran1[0] == True
     assert ran2[0] == True
 def test_currentthread_ensuretrampoline_and_cancel(self):
     scheduler = CurrentThreadScheduler()
     ran1, ran2 = [False], [False]
 
     def outer_action(scheduler, state):
         def inner_action1(scheduler, state):
             ran1[0] = True
 
             def inner_action2(scheduler, state):
                 ran2[0] = True
 
             d = scheduler.schedule(inner_action2)
             d.dispose()
 
         return scheduler.schedule(inner_action1)
 
     scheduler.ensure_trampoline(outer_action)
     assert ran1[0] == True
     assert ran2[0] == False
    def test_currentthread_ensuretrampoline_and_cancel(self):
        scheduler = CurrentThreadScheduler()
        ran1, ran2 = [False], [False]

        def outer_action(scheduler, state):
            def inner_action1(scheduler, state):
                ran1[0] = True

                def inner_action2(scheduler, state):
                    ran2[0] = True

                d = scheduler.schedule(inner_action2)
                d.dispose()

            return scheduler.schedule(inner_action1)

        scheduler.ensure_trampoline(outer_action)
        assert ran1[0] == True
        assert ran2[0] == False
    def test_currentthread_ensuretrampoline(self):
        scheduler = CurrentThreadScheduler()
        ran1, ran2 = False, False

        def outer_action(scheduer, state=None):
            def action1(scheduler, state=None):
                nonlocal ran1
                ran1 = True

            scheduler.schedule(action1)

            def action2(scheduler, state=None):
                nonlocal ran2
                ran2 = True

            return scheduler.schedule(action2)

        scheduler.ensure_trampoline(outer_action)
        assert ran1 is True
        assert ran2 is True
def test_currentthread_ensuretrampoline_nested():
    scheduler = CurrentThreadScheduler()
    ran1, ran2 = False, False

    def outer_action(scheduler, state):
        def inner_action1(scheduler, state):
            nonlocal ran1
            ran1 = True

        scheduler.ensure_trampoline(inner_action1)

        def inner_action2(scheduler, state):
            nonlocal ran2
            ran2 = True

        return scheduler.ensure_trampoline(inner_action2)

    scheduler.ensure_trampoline(outer_action)
    assert ran1 == True
    assert ran2 == True
Beispiel #7
0
    def test_currentthread_ensuretrampoline(self):
        scheduler = CurrentThreadScheduler()
        ran1, ran2 = False, False

        def outer_action(scheduer, state=None):
            def action1(scheduler, state=None):
                nonlocal ran1
                ran1 = True

            scheduler.schedule(action1)

            def action2(scheduler, state=None):
                nonlocal ran2
                ran2 = True

            return scheduler.schedule(action2)

        scheduler.ensure_trampoline(outer_action)
        assert ran1 is True
        assert ran2 is True
def test_currentthread_ensuretrampoline_nested():
    scheduler = CurrentThreadScheduler()
    ran1, ran2 = False, False

    def outer_action(scheduler, state):
        def inner_action1(scheduler, state):
            nonlocal ran1
            ran1 = True
        
        scheduler.ensure_trampoline(inner_action1)
        
        def inner_action2(scheduler, state):
            nonlocal ran2
            ran2 = True
        
        return scheduler.ensure_trampoline(inner_action2)

    scheduler.ensure_trampoline(outer_action)
    assert ran1 == True
    assert ran2 == True
    def test_currentthread_ensuretrampoline_and_cancel(self):
        scheduler = CurrentThreadScheduler()
        ran1, ran2 = False, False

        def outer_action(scheduler, state):
            def inner_action1(scheduler, state):
                nonlocal ran1
                ran1 = True

                def inner_action2(scheduler, state):
                    nonlocal ran2
                    ran2 = True

                d = scheduler.schedule(inner_action2)
                d.dispose()

            return scheduler.schedule(inner_action1)

        scheduler.ensure_trampoline(outer_action)
        assert ran1 is True
        assert ran2 is False
def test_currentthread_ensuretrampoline_and_cancel():
    scheduler = CurrentThreadScheduler()
    ran1, ran2 = False, False

    def outer_action(scheduler, state):
        def inner_action1(scheduler, state):
            nonlocal ran1
            ran1 = True

            def inner_action2(scheduler, state):
                nonlocal ran2
                ran2 = True

            d = scheduler.schedule(inner_action2)
            d.dispose()

        return scheduler.schedule(inner_action1)

    scheduler.ensure_trampoline(outer_action)
    assert ran1 == True
    assert ran2 == False
def test_currentthread_ensuretrampoline_and_canceltimed():
    scheduler = CurrentThreadScheduler()
    ran1, ran2 = False, False
    
    def outer_action(scheduler, state):
        def inner_action1(scheduler, state):
            nonlocal ran1
            ran1 = True

            def inner_action2(scheduler, state):
                nonlocal ran2
                ran2 = True

            d = scheduler.schedule_relative(timedelta(milliseconds=500), inner_action2)
            d.dispose()

        return scheduler.schedule(inner_action1)

    scheduler.ensure_trampoline(outer_action)
    assert ran1 == True
    assert ran2 == False
Beispiel #12
0
    def test_currentthread_ensuretrampoline_and_canceltimed(self):
        scheduler = CurrentThreadScheduler()
        ran1, ran2 = False, False

        def outer_action(scheduler, state):
            def inner_action1(scheduler, state):
                nonlocal ran1
                ran1 = True

                def inner_action2(scheduler, state):
                    nonlocal ran2
                    ran2 = True

                t = scheduler.now + timedelta(seconds=0.5)
                d = scheduler.schedule_absolute(t, inner_action2)
                d.dispose()

            return scheduler.schedule(inner_action1)

        scheduler.ensure_trampoline(outer_action)
        assert ran1 is True
        assert ran2 is False