Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 import os
00035 import sys
00036 import struct
00037 import unittest
00038 import time
00039
00040 class TestRospyExceptions(unittest.TestCase):
00041
00042 def test_exceptions(self):
00043
00044 from rospy.exceptions import ROSException, ROSSerializationException, ROSInternalException, ROSInitException, \
00045 TransportException, TransportTerminated, TransportInitError
00046
00047 for e in [ROSException, ROSInitException, ROSSerializationException]:
00048 exc = e('foo')
00049 self.assert_(isinstance(exc, ROSException))
00050 for e in [ROSInternalException,
00051 TransportException, TransportTerminated, TransportInitError]:
00052 exc = e('foo')
00053 self.assert_(isinstance(exc, ROSInternalException))
00054
00055 def test_ROSInterruptException(self):
00056 from rospy.exceptions import ROSInterruptException, ROSException
00057 try:
00058 raise ROSInterruptException("test")
00059 except ROSException:
00060 pass
00061 try:
00062 raise ROSInterruptException("test")
00063 except KeyboardInterrupt:
00064 pass
00065
00066 def test_ROSTimeMovedBackwardsException(self):
00067 from rospy.exceptions import ROSTimeMovedBackwardsException, ROSInterruptException
00068 try:
00069 raise ROSTimeMovedBackwardsException(1.0)
00070 except ROSInterruptException as e:
00071
00072 self.assertEqual("ROS time moved backwards", e.message)
00073 try:
00074 time = 1.0
00075 raise ROSTimeMovedBackwardsException(time)
00076 except ROSTimeMovedBackwardsException as e:
00077 self.assertEqual(time, e.time)