Go to the documentation of this file.00001
00002
00003 import rospy
00004 import rostest
00005 from std_msgs.msg import Int32
00006 import sys
00007 from time import sleep
00008 import unittest
00009
00010 PKG = 'swri_nodelet'
00011 NAME = 'test_nodelet_exists'
00012
00013 class TestNodeletExists(unittest.TestCase):
00014
00015 def callback(self, msg):
00016 self.msg = msg
00017
00018 def test_init(self):
00019 '''
00020 Test that the test nodelet exists by waiting for the message it
00021 publishes.
00022 '''
00023 self.msg = None
00024 sub = rospy.Subscriber('numbers', Int32, self.callback)
00025 while self.msg is None:
00026 sleep(0.1)
00027 sub.unregister()
00028 self.assertEquals(self.msg.data, 1337)
00029
00030 if __name__ == '__main__':
00031 rospy.init_node(NAME)
00032 rostest.rosrun(PKG, NAME, TestNodeletExists, sys.argv)