Skip to content

Commit ea7d1b7

Browse files
committed
Add more asserts
1 parent 3366aeb commit ea7d1b7

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

flexbe_core/src/flexbe_core/core/concurrency_container.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ def _execute_current_state(self):
5050
# but is required here to reset the sleep time after executing
5151
state.sleep()
5252

53-
Logger.loginfo("BEFORE: state.sleep_duration({ssd}) if sleep_dur({sd}) is None else "
54-
"min(sleep_dur, state.sleep_duration)({m})"
55-
.format(ssd=state.sleep_duration, sd=sleep_dur, m=min(sleep_dur, state.sleep_duration)))
53+
Logger.loginfo("BEFORE: state.sleep_duration({ssd}) if sleep_dur({sd}) is None else".format(ssd=state.sleep_duration, sd=sleep_dur))
5654
sleep_dur = state.sleep_duration if sleep_dur is None else min(sleep_dur, state.sleep_duration)
5755
Logger.loginfo("AFTER: sleep_dur={sd}".format(sd=sleep_dur))
5856
if sleep_dur > 0:

flexbe_core/test/test_core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,14 @@ def sleep(self):
355355
pass
356356

357357
# all states are called with their correct rate
358+
self.assertEquals(cc.sleep_duration, 0., msg="cc.sleep_duration should be 0. before executing")
358359
cc.execute(None)
360+
self.assertAlmostEqual(cc.sleep_duration, .1, delta=0.05, msg="After executing once, cc.sleep_duration should be set to the duration of the 'fastest' state")
359361
cc.sleep()
362+
self.assertAlmostEqual(cc.sleep_duration, .0, delta=0.05, msg="After sleeping once, cc.sleep_duration should be reset to 0")
360363
cc.execute(None)
361364
rospy.logwarn("self.assertAlmostEqual(cc.sleep_duration, .1, places=2)")
362-
self.assertAlmostEqual(cc.sleep_duration, .1, places=2)
365+
self.assertAlmostEqual(cc.sleep_duration, .1, delta=0.05, msg="After executing twice, cc.sleep_duration should be set to the duration of the 'fastest' state")
363366
cc.sleep()
364367
cc['main'].set_rate(15)
365368
cc['side'].set_rate(10)

0 commit comments

Comments
 (0)