示例#1
0
 def test_commandandfile(self):
     dir = roslib.packages.get_pkg_dir('roslaunch')
     f = open(os.path.join(dir, 'example.launch'), 'r')
     data = f.read()
     f.close()
     test_file = data
     self.assertEquals(get_param("commandoutput"), test_file)
     self.assertEquals(get_param("textfile"), test_file)
     ## test 'binfile' attribute
     import xmlrpclib
     bindata = get_param("binaryfile")
     self.assertTrue(isinstance(bindata, xmlrpclib.Binary))
     self.assertEquals(bindata.data, test_file)
示例#2
0
 def test_ns(self):
     self.assertEquals(get_param("/wg/childparam"), "wg")
     self.assertEquals(get_param("/wg2/childparam"), "wg2")
     self.assertEquals(get_param("/wg3/childparam"), "wg3")
     self.assertEquals(get_param("/wg/wg4/childparam"), "wg4")
     self.assertEquals(get_param("/wg/wg4/wg5/childparam"), "wg5")
     ## Test roslaunch <group> tag with and without ns attribute
     self.assertEquals(get_param("/wga/wg/childparam"), "wg")
     self.assertEquals(get_param("/wga/wg2/childparam"), "wg2")
     self.assertEquals(get_param("/wga/wg3/childparam"), "wg3")
     self.assertEquals(get_param("/wga/wg/wg4/childparam"), "wg4")
     self.assertEquals(get_param("/wga/wg/wg4/wg5/childparam"), "wg5")
     # test second-level group
     self.assertEquals(get_param("/wga/wgb/wg/childparam"), "bwg")
     self.assertEquals(get_param("/wga/wgb/wg2/childparam"), "bwg2")
     self.assertEquals(get_param("/wga/wgb/wg3/childparam"), "bwg3")
     self.assertEquals(get_param("/wga/wgb/wg/wg4/childparam"), "bwg4")
     self.assertEquals(get_param("/wga/wgb/wg/wg4/wg5/childparam"), "bwg5")
     # test unscoped group
     self.assertEquals(get_param("/wgc/childparam"), "wg")
     self.assertEquals(get_param("/wgc2/childparam"), "wg2")
     self.assertEquals(get_param("/wgc3/childparam"), "wg3")
     self.assertEquals(get_param("/wgc/wg4/childparam"), "wg4")
     self.assertEquals(get_param("/wgc/wg4/wg5/childparam"), "wg5")
示例#3
0
 def test_values(self):
     ## Test roslaunch string params
     self.assertEquals(get_param('stringempty'), '')
     print get_param('stringbar')
     self.assertEquals(get_param('stringbar'), 'bar')
     self.assertEquals(get_param('str10'), '10')
     self.assertEquals(get_param('string10'), '10')
     self.assertEquals(get_param('stringentity'), '<stringentity/>')
     ## Test roslaunch integer params
     self.assertEquals(get_param("integerneg1"), -1)
     self.assertEquals(get_param("integer0"), 0)
     self.assertEquals(get_param("integer1"), 1)
     self.assertEquals(get_param("integernoop1"), 1)
     self.assertEquals(get_param("integer12345"), 12345)
     ## Test roslaunch float params
     self.assertEquals(get_param("floatpi"), 3.14159)
     self.assertEquals(get_param("floatnooppi"), 3.14159)
     self.assertEquals(get_param("float3"), 3.0)
     self.assertEquals(get_param("floatneg1"), -1.0)
     ## Test roslaunch boolean params
     for p in ['true', 'TRUE', 'True']:
         self.assertTrue(get_param(p),
                         "[%s] is not false: %s" % (p, get_param(p)))
     for p in ['false', "FALSE", 'False']:
         self.assertFalse(get_param(p),
                          "[%s] is not false: %s" % (p, get_param(p)))