Пример #1
0
 def test_should_handle_many_intervals_seeking_forward(self):
   self._routine.create_interval(5)  #  5
   self._routine.create_interval(10) # 15
   self._routine.create_interval(15) # 30
   self._routine.create_interval(10) # 40
   self._routine.create_interval(5)  # 45
   testhelper.assert_range(range(0, 3), self._seek(20.0))
   testhelper.assert_close(self._routine.intervals[0].completed(), 5.0)
   testhelper.assert_close(self._routine.intervals[1].completed(), 10.0)
   testhelper.assert_close(self._routine.intervals[2].completed(), 5.0)
   testhelper.assert_close(self._routine.intervals[3].completed(), 0.0)
   testhelper.assert_close(self._routine.intervals[4].completed(), 0.0)
   testhelper.assert_range(range(2, 3), self._seek(30.0))
   testhelper.assert_close(self._routine.intervals[0].completed(), 5.0)
   testhelper.assert_close(self._routine.intervals[1].completed(), 10.0)
   testhelper.assert_close(self._routine.intervals[2].completed(), 15.0)
   testhelper.assert_close(self._routine.intervals[3].completed(), 0.0)
   testhelper.assert_close(self._routine.intervals[4].completed(), 0.0)
   testhelper.assert_range(range(3, 4), self._seek(35.0))
   testhelper.assert_close(self._routine.intervals[0].completed(), 5.0)
   testhelper.assert_close(self._routine.intervals[1].completed(), 10.0)
   testhelper.assert_close(self._routine.intervals[2].completed(), 15.0)
   testhelper.assert_close(self._routine.intervals[3].completed(), 5.0)
   testhelper.assert_close(self._routine.intervals[4].completed(), 0.0)
   testhelper.assert_range(range(3, 5), self._seek(100.0))
   for i in range(0, 5):
     testhelper.assert_close(self._routine.intervals[i].completed(), self._routine.intervals[i].time)
   testhelper.assert_range(range(5, 5), self._seek(100.0))
Пример #2
0
def test_assert_range():
  testhelper.assert_range(range(0, 0), range(0, 0))
  testhelper.assert_range(range(0, 1), range(0, 1))
  testhelper.assert_range(range(0, 100, 4), range(0, 100, 4))
  with pytest.raises(AssertionError):
    testhelper.assert_range(range(0, 1), range(0, 0))
  with pytest.raises(AssertionError):
    testhelper.assert_range(range(0, 0), range(0, 1))
Пример #3
0
 def test_should_handle_running_intervals_when_seeking_backward(self):
   self._routine.create_interval(5)  #  5
   self._routine.create_interval(10) # 15
   self._routine.create_interval(15) # 30
   self._routine.create_interval(10) # 40
   self._routine.create_interval(5)  # 45
   for i in range(0, 4):
     self._routine.intervals[i].seek(self._routine.intervals[i].time)
   testhelper.assert_range(range(3, 1), self._seek(0.0))
Пример #4
0
 def test_should_handle_two_intervals_incrementally_seeking_forward(self):
   self._routine.create_interval(5)
   self._routine.create_interval(10)
   testhelper.assert_range(range(0, 1), self._seek(2.5))
   testhelper.assert_close(self._routine.intervals[0].completed(), 2.5)
   testhelper.assert_close(self._routine.intervals[1].completed(), 0.0)
   testhelper.assert_range(range(0, 1), self._seek(5.0))
   testhelper.assert_close(self._routine.intervals[0].completed(), 5.0)
   testhelper.assert_close(self._routine.intervals[1].completed(), 0.0)
   testhelper.assert_range(range(1, 2), self._seek(10.0))
   testhelper.assert_close(self._routine.intervals[0].completed(), 5.0)
   testhelper.assert_close(self._routine.intervals[1].completed(), 5.0)
   testhelper.assert_range(range(1, 2), self._seek(15.0))
   testhelper.assert_close(self._routine.intervals[0].completed(), 5.0)
   testhelper.assert_close(self._routine.intervals[1].completed(), 10.0)
Пример #5
0
 def test_should_handle_one_interval_seeking_backward(self):
   self._routine.create_interval(5)
   self._routine.seek(self._routine.time())
   testhelper.assert_range(range(0, 1), self._seek(2.5))
   testhelper.assert_close(self._routine.intervals[0].completed(), 2.5)
   testhelper.assert_range(range(0, 1), self._seek(0.0))
   testhelper.assert_close(self._routine.intervals[0].completed(), 0.0)
   testhelper.assert_range(range(0, 0), self._seek(-5.0))
   testhelper.assert_close(self._routine.intervals[0].completed(), 0.0)
Пример #6
0
 def test_should_handle_a_null_routine_seeking_backward(self):
   testhelper.assert_range(range(0, 0), self._seek(0.0))
   testhelper.assert_range(range(0, 0), self._seek(10.0))
Пример #7
0
 def test_should_handle_one_interval_seeking_forward(self):
   self._routine.create_interval(5)
   testhelper.assert_range(range(0, 1), self._seek(2.5))
   testhelper.assert_close(self._routine.intervals[0].completed(), 2.5)
   testhelper.assert_range(range(0, 1), self._seek(10.0))
   testhelper.assert_close(self._routine.intervals[0].completed(), 5.0)