class ITimeStepStateTest(TestCase): def setUp(self): self._default = ITimeStepState(num_states=3) self.assertIs(len(self._default), 3) def test_has_same_features_as_state_iterator(self): self.setUp() is_iterable(self._default, IStepState, 3) self.setUp() has_current_accessor(self._default) self.setUp() has_previous_accessor(self._default) self.setUp() has_next_accessor(self._default) self.setUp() has_first_and_last_accessor(self._default) self.setUp() on_finalize_collect_solutions_and_finalize(self._default) def test_provides_delta_time_step(self): self.assertEqual(self._default.delta_time_step, 0.0) self._default.delta_time_step = 1.0 self.assertIs(self._default.delta_time_step, 1.0) with self.assertRaises(ValueError): self._default.delta_time_step = -3.4 def test_has_initial_state(self): self.assertIsNotNone(self._default.initial) def test_has_proxies_for_step_time_points(self): self._default.proceed() self.assertIs(self._default.current_time_point, self._default.current_step.time_point) self.assertIs(self._default.previous_time_point, self._default.previous_step.time_point) self.assertIs(self._default.next_time_point, self._default.next_step.time_point) self.assertIs(self._default.time_points.size, 3) def test_has_aliases_for_state_accessors(self): self.assertIs(self._default.current_step, self._default.current) self.assertIs(self._default.current_step_index, self._default.current_index) self.assertIs(self._default.next_step, self._default.next) self.assertIs(self._default.next_step_index, self._default.next_index) self.assertIs(self._default.last_step, self._default.last) self.assertIs(self._default.last_step_index, self._default.last_index) self.assertIs(self._default.previous_step, self._default.initial) self.assertIsNone(self._default.previous_step_index) self._default.proceed() self.assertIs(self._default.current_step, self._default.current) self.assertIs(self._default.current_step_index, self._default.current_index) self.assertIs(self._default.previous_step, self._default.previous) self.assertIs(self._default.previous_step_index, self._default.previous_index) self.assertIs(self._default.next_step, self._default.next) self.assertIs(self._default.next_step_index, self._default.next_index) self.assertIs(self._default.last_step, self._default.last) self.assertIs(self._default.last_step_index, self._default.last_index)
def setUp(self): self._default = ITimeStepState(num_states=3) self.assertIs(len(self._default), 3)