test_nodelet_exists.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 import rostest
5 from std_msgs.msg import Int32
6 import sys
7 from time import sleep
8 import unittest
9 
10 PKG = 'swri_nodelet'
11 NAME = 'test_nodelet_exists'
12 
13 class TestNodeletExists(unittest.TestCase):
14 
15  def callback(self, msg):
16  self.msg = msg
17 
18  def test_init(self):
19  '''
20  Test that the test nodelet exists by waiting for the message it
21  publishes.
22  '''
23  self.msg = None
24  sub = rospy.Subscriber('numbers', Int32, self.callback)
25  while self.msg is None:
26  sleep(0.1)
27  sub.unregister()
28  self.assertEqual(self.msg.data, 1337)
29 
30 if __name__ == '__main__':
31  rospy.init_node(NAME)
32  rostest.rosrun(PKG, NAME, TestNodeletExists, sys.argv)


swri_nodelet
Author(s):
autogenerated on Tue Apr 6 2021 02:50:32