20 from unittest
import TestCase
22 PKG =
"sr_robot_commander" 27 Tests the state saver raises exceptions when launched with no hardware present. 31 rospy.init_node(
'test_state_saver_no_hardware', anonymous=
True)
34 exception_raised =
False 39 except Exception
as e:
40 exception_raised =
True 41 exception_string = str(e)
43 self.assertTrue(exception_raised)
44 self.assertEqual(exception_string,
"Cannot save with empty name.")
47 exception_raised =
False 52 except Exception
as e:
53 exception_raised =
True 54 exception_string = str(e)
56 self.assertTrue(exception_raised)
57 self.assertEqual(exception_string,
"'No hand found.'")
60 exception_raised =
False 65 except Exception
as e:
66 exception_raised =
True 67 exception_string = str(e)
69 self.assertTrue(exception_raised)
70 self.assertEqual(exception_string,
"'No arm found.'")
73 exception_raised =
False 78 except Exception
as e:
79 exception_raised =
True 80 exception_string = str(e)
82 self.assertTrue(exception_raised)
83 self.assertEqual(exception_string,
"'No hand found.' 'No arm found.'")
86 if __name__ ==
"__main__":
88 rostest.rosrun(PKG,
"test_state_saver_no_hardware", TestSrStateSaverExceptions)