test_urdf_files.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # Copyright (c) 2016 The UUV Simulator Authors.
3 # All rights reserved.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 from __future__ import print_function
17 import rospy
18 import unittest
19 import subprocess
20 import os
21 
22 PKG = 'uuv_descriptions'
23 NAME = 'test_urdf_files'
24 
25 import roslib
26 roslib.load_manifest(PKG)
27 
28 
29 def call_xacro(xml_file):
30  assert os.path.isfile(xml_file), 'Invalid XML xacro file'
31  return subprocess.check_output(['xacro', '--inorder', xml_file])
32 
33 
34 class TestRexROVURDFFiles(unittest.TestCase):
35  def test_xacro(self):
36  # Retrieve the root folder for the tests
37  test_dir = os.path.abspath(os.path.dirname(__file__))
38  robots_dir = os.path.join(test_dir, '..', 'robots')
39 
40  for item in os.listdir(robots_dir):
41  if 'oberon' in item:
42  continue
43  if not os.path.isfile(os.path.join(robots_dir, item)):
44  continue
45  output = call_xacro(os.path.join(robots_dir, item))
46  self.assertNotIn(
47  output,
48  'XML parsing error',
49  'Parsing error found for file {}'.format(item))
50  self.assertNotIn(
51  output,
52  'No such file or directory',
53  'Some file not found in {}'.format(item))
54 
55 if __name__ == '__main__':
56  import rosunit
57  rosunit.unitrun(PKG, NAME, TestRexROVURDFFiles)
58 
59 
60 
def call_xacro(xml_file)


uuv_descriptions
Author(s): Musa Morena Marcusso Manhaes , Sebastian Scherer , Luiz Ricardo Douat
autogenerated on Mon Jul 1 2019 19:39:24