Пример #1
0
def test_pop_until():
    timeline = Timeline([('event 1', 1.), ('event 2', .5)])
    events = timeline.pop_until(.2)
    assert_list_equal([], events)
    assert_equal(.2, timeline.time)

    events = timeline.pop_until(1.)
    assert_list_equal(['event 2', 'event 1', 'event 2'], events)
    assert_equal(1., timeline.time)
Пример #2
0
def test_pop_until():
    timeline = Timeline([("event 1", 1.0), ("event 2", 0.5)])
    events = timeline.pop_until(0.2)
    assert events == []
    assert timeline.time == approx(0.2)

    events = timeline.pop_until(1.0)
    assert events == ["event 2", "event 1", "event 2"]
    assert timeline.time == approx(1.0)
Пример #3
0
def test_pop_until():
    timeline = Timeline([("event 1", 1.0), ("event 2", 0.5)])
    events = timeline.pop_until(0.2)
    assert events == []
    assert timeline.time == approx(0.2)

    events = timeline.pop_until(1.0)
    assert events == ["event 2", "event 1", "event 2"]
    assert timeline.time == approx(1.0)
Пример #4
0
def test_one_time_event():
    timeline = Timeline([
        ('recurring-event', 1.),
    ])
    timeline.add_one_time_event('one-timer', .1)
    events = timeline.pop_until(2.)
    assert_list_equal(events,
                      ['one-timer', 'recurring-event', 'recurring-event'])
Пример #5
0
def test_non_zero_start():
    timeline = Timeline([("event 1", 1.0), ("event 2", 0.25)], start=-1)
    assert timeline.time_of_next_event == approx(-0.75)
    assert timeline.pop_until(0.0) == [
        "event 2",
        "event 2",
        "event 2",
        "event 1",
        "event 2",
    ]
Пример #6
0
def test_non_zero_start():
    timeline = Timeline([("event 1", 1.0), ("event 2", 0.25)], start=-1)
    assert timeline.time_of_next_event == approx(-0.75)
    assert timeline.pop_until(0.0) == [
        "event 2",
        "event 2",
        "event 2",
        "event 1",
        "event 2",
    ]
Пример #7
0
def test_non_zero_start():
    timeline = Timeline([('event 1', 1.), ('event 2', .25)], start=-1)
    assert_equal(timeline.time_of_next_event, -.75)
    assert_list_equal(timeline.pop_until(0.),
                      ['event 2', 'event 2', 'event 2', 'event 1', 'event 2'])
Пример #8
0
def test_one_time_event():
    timeline = Timeline([("recurring-event", 1.0)])
    timeline.add_one_time_event("one-timer", 0.1)
    events = timeline.pop_until(2.0)
    assert events == ["one-timer", "recurring-event", "recurring-event"]
Пример #9
0
def test_one_time_event():
    timeline = Timeline([("recurring-event", 1.0)])
    timeline.add_one_time_event("one-timer", 0.1)
    events = timeline.pop_until(2.0)
    assert events == ["one-timer", "recurring-event", "recurring-event"]