test_rospy_api.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # Software License Agreement (BSD License)
3 #
4 # Copyright (c) 2008, Willow Garage, Inc.
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 #
11 # * Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # * Redistributions in binary form must reproduce the above
14 # copyright notice, this list of conditions and the following
15 # disclaimer in the documentation and/or other materials provided
16 # with the distribution.
17 # * Neither the name of Willow Garage, Inc. nor the names of its
18 # contributors may be used to endorse or promote products derived
19 # from this software without specific prior written permission.
20 #
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 # POSSIBILITY OF SUCH DAMAGE.
33 
34 import os
35 import sys
36 import struct
37 import unittest
38 import time
39 
40 # test rospy API verifies that the rospy module exports the required symbols
41 class TestRospyApi(unittest.TestCase):
42 
43  def test_msg(self):
44  # rospy.Message really only exists at the client level, as the internal
45  # implementation is built around the roslib reference, so we put the test here
46 
47  import rospy
48  #trip wires against Message API
49  m = rospy.Message()
50  try:
51  from cStringIO import StringIO
52  except ImportError:
53  from io import StringIO
54  buff = StringIO()
55  m.serialize(buff)
56  self.assertEquals(0, buff.tell())
57  m.deserialize('')
58 
59  def test_anymsg(self):
60  # rospy.AnyMsg really only exists at the client level as nothing within
61  # rospy uses its functionality.
62 
63 
64  try:
65  from cStringIO import StringIO
66  except ImportError:
67  from io import StringIO
68  import rospy
69  import rospy.exceptions
70  #trip wires against AnyMsg API
71  m = rospy.AnyMsg()
72  try:
73  m.serialize(StringIO())
74  self.fail("AnyMsg should not allow serialization")
75  except rospy.exceptions.ROSException:
76  pass
77 
78  teststr = 'foostr-%s'%time.time()
79  m.deserialize(teststr)
80  self.assertEquals(teststr, m._buff)
81 
82  #test AnyMsg ctor error checking
83  try:
84  m = rospy.AnyMsg('foo')
85  self.fail("AnyMsg ctor should not allow args")
86  except: pass
87 
88  def test_rospy_api(self):
89  import rospy
90 
91  # just a laundry list of API methods to make sure that they still exist
92 
93  # removed
94  try:
95  rospy.add_shutdown_hook
96  self.fail("add_shutdown_hookshould not longer be top-level API")
97  except AttributeError: pass
98 
99  rospy.DEBUG
100  rospy.INFO
101  rospy.WARN
102  rospy.ERROR
103  rospy.FATAL
104 
105  rospy.get_caller_id
106  rospy.get_name
107  rospy.get_master
108  rospy.get_namespace
109  rospy.get_published_topics
110  rospy.get_node_uri
111  rospy.get_ros_root
112  rospy.get_time
113  rospy.get_rostime
114  rospy.init_node
115  rospy.is_shutdown
116  rospy.logdebug
117  rospy.logerr
118  rospy.logfatal
119  rospy.loginfo
120  rospy.logout #deprecated
121  rospy.logwarn
122  rospy.logdebug_throttle
123  rospy.logerr_throttle
124  rospy.logfatal_throttle
125  rospy.loginfo_throttle
126  rospy.logwarn_throttle
127  rospy.myargv
128  rospy.on_shutdown
129  rospy.parse_rosrpc_uri
130  rospy.resolve_name
131  rospy.remap_name
132  rospy.signal_shutdown
133  rospy.sleep
134  rospy.spin
135  rospy.wait_for_message
136  rospy.wait_for_service
137 
138  rospy.delete_param
139  rospy.get_param
140  rospy.get_param_names
141  rospy.has_param
142  rospy.set_param
143  rospy.search_param
144 
145  rospy.AnyMsg
146  rospy.Duration
147  rospy.Header
148  rospy.MasterProxy
149  rospy.Message
150  rospy.Publisher
151  rospy.Rate
152  rospy.ROSException
153  rospy.ROSInternalException
154  rospy.ROSSerializationException
155  rospy.ServiceException
156  rospy.Service
157  rospy.ServiceProxy
158  rospy.SubscribeListener
159  rospy.Subscriber
160  rospy.Time
161  rospy.TransportException
162  rospy.TransportTerminated
163  rospy.TransportInitError


test_rospy
Author(s): Ken Conley, Dirk Thomas
autogenerated on Mon Nov 2 2020 03:52:56