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)
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)
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)
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())
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()
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()
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())
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())
def test_pop_empty_timeline(): timeline = Timeline() with assert_raises(IndexError): timeline.pop()
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()
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()
def test_pop_empty_timeline(): timeline = Timeline() with pytest.raises(IndexError): timeline.pop()
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()
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()
def test_pop_empty_timeline(): timeline = Timeline() with pytest.raises(IndexError): timeline.pop()