コード例 #1
0
ファイル: test_timeline.py プロジェクト: PeishiJiang/pymt
def test_pop_events():
    timeline = Timeline([('event 1', 1.), ('event 2', .25)])
    for time in [.25, .5, .75]:
        assert_equal('event 2', timeline.pop())
        assert_equal(time, timeline.time)
    assert_equal('event 1', timeline.pop())
    assert_equal(1., timeline.time)

    assert_equal('event 2', timeline.pop())
    assert_equal(1., timeline.time)
コード例 #2
0
ファイル: test_timeline.py プロジェクト: csdms/pymt
def test_pop_events():
    timeline = Timeline([("event 1", 1.0), ("event 2", 0.25)])
    for time in [0.25, 0.5, 0.75]:
        assert timeline.pop() == "event 2"
        assert timeline.time == approx(time)
    assert timeline.pop() == "event 1"
    assert timeline.time == approx(1.0)

    assert timeline.pop() == "event 2"
    assert timeline.time == approx(1.0)
コード例 #3
0
def test_pop_events():
    timeline = Timeline([("event 1", 1.0), ("event 2", 0.25)])
    for time in [0.25, 0.5, 0.75]:
        assert timeline.pop() == "event 2"
        assert timeline.time == approx(time)
    assert timeline.pop() == "event 1"
    assert timeline.time == approx(1.0)

    assert timeline.pop() == "event 2"
    assert timeline.time == approx(1.0)
コード例 #4
0
ファイル: test_timeline.py プロジェクト: PeishiJiang/pymt
def test_repeated_events():
    (first_event, second_event) = (dict(foo='bar'), dict(bar='baz'))
    timeline = Timeline([(first_event, .5), (second_event, 1.),
                         (first_event, .75)])
    assert_is(first_event, timeline.pop())
    assert_is(first_event, timeline.pop())
    assert_is(second_event, timeline.pop())
    assert_is(first_event, timeline.pop())

    timeline = Timeline([
        (first_event, .5),
        (second_event, 1.),
        (first_event, 1.),
    ])
    assert_is(first_event, timeline.pop())
    assert_is(second_event, timeline.pop())
    assert_is(first_event, timeline.pop())
    assert_is(first_event, timeline.pop())

    timeline = Timeline([
        (first_event, .5),
        (first_event, 1.),
        (second_event, 1.),
    ])
    assert_is(first_event, timeline.pop())
    assert_is(first_event, timeline.pop())
    assert_is(second_event, timeline.pop())
    assert_is(first_event, timeline.pop())
コード例 #5
0
ファイル: test_timeline.py プロジェクト: csdms/pymt
def test_repeated_events():
    (first_event, second_event) = (dict(foo="bar"), dict(bar="baz"))
    timeline = Timeline([(first_event, 0.5), (second_event, 1.0), (first_event, 0.75)])
    assert first_event is timeline.pop()
    assert first_event is timeline.pop()
    assert second_event is timeline.pop()
    assert first_event is timeline.pop()

    timeline = Timeline([(first_event, 0.5), (second_event, 1.0), (first_event, 1.0)])
    assert first_event is timeline.pop()
    assert second_event is timeline.pop()
    assert first_event is timeline.pop()
    assert first_event is timeline.pop()

    timeline = Timeline([(first_event, 0.5), (first_event, 1.0), (second_event, 1.0)])
    assert first_event is timeline.pop()
    assert first_event is timeline.pop()
    assert second_event is timeline.pop()
    assert first_event is timeline.pop()
コード例 #6
0
def test_repeated_events():
    (first_event, second_event) = (dict(foo="bar"), dict(bar="baz"))
    timeline = Timeline([(first_event, 0.5), (second_event, 1.0),
                         (first_event, 0.75)])
    assert first_event is timeline.pop()
    assert first_event is timeline.pop()
    assert second_event is timeline.pop()
    assert first_event is timeline.pop()

    timeline = Timeline([(first_event, 0.5), (second_event, 1.0),
                         (first_event, 1.0)])
    assert first_event is timeline.pop()
    assert second_event is timeline.pop()
    assert first_event is timeline.pop()
    assert first_event is timeline.pop()

    timeline = Timeline([(first_event, 0.5), (first_event, 1.0),
                         (second_event, 1.0)])
    assert first_event is timeline.pop()
    assert first_event is timeline.pop()
    assert second_event is timeline.pop()
    assert first_event is timeline.pop()
コード例 #7
0
ファイル: test_timeline.py プロジェクト: PeishiJiang/pymt
def test_unhashable_event():
    (first_event, second_event) = (dict(foo='bar'), dict(bar='baz'))
    timeline = Timeline([(first_event, .5), (second_event, 1.)])
    assert_is(first_event, timeline.pop())
    assert_is(second_event, timeline.pop())
    assert_is(first_event, timeline.pop())
コード例 #8
0
ファイル: test_timeline.py プロジェクト: PeishiJiang/pymt
def test_hashable_event():
    timeline = Timeline([(('event', 2), .5), (('event', 0), 1.)])
    assert_tuple_equal(('event', 2), timeline.pop())
    assert_tuple_equal(('event', 0), timeline.pop())
    assert_tuple_equal(('event', 2), timeline.pop())
コード例 #9
0
ファイル: test_timeline.py プロジェクト: PeishiJiang/pymt
def test_pop_empty_timeline():
    timeline = Timeline()
    with assert_raises(IndexError):
        timeline.pop()
コード例 #10
0
def test_unhashable_event():
    (first_event, second_event) = (dict(foo="bar"), dict(bar="baz"))
    timeline = Timeline([(first_event, 0.5), (second_event, 1.0)])
    assert first_event is timeline.pop()
    assert second_event is timeline.pop()
    assert first_event is timeline.pop()
コード例 #11
0
def test_hashable_event():
    timeline = Timeline([(("event", 2), 0.5), (("event", 0), 1.0)])
    assert ("event", 2) == timeline.pop()
    assert ("event", 0) == timeline.pop()
    assert ("event", 2) == timeline.pop()
コード例 #12
0
def test_pop_empty_timeline():
    timeline = Timeline()
    with pytest.raises(IndexError):
        timeline.pop()
コード例 #13
0
ファイル: test_timeline.py プロジェクト: csdms/pymt
def test_unhashable_event():
    (first_event, second_event) = (dict(foo="bar"), dict(bar="baz"))
    timeline = Timeline([(first_event, 0.5), (second_event, 1.0)])
    assert first_event is timeline.pop()
    assert second_event is timeline.pop()
    assert first_event is timeline.pop()
コード例 #14
0
ファイル: test_timeline.py プロジェクト: csdms/pymt
def test_hashable_event():
    timeline = Timeline([(("event", 2), 0.5), (("event", 0), 1.0)])
    assert ("event", 2) == timeline.pop()
    assert ("event", 0) == timeline.pop()
    assert ("event", 2) == timeline.pop()
コード例 #15
0
ファイル: test_timeline.py プロジェクト: csdms/pymt
def test_pop_empty_timeline():
    timeline = Timeline()
    with pytest.raises(IndexError):
        timeline.pop()