|
| 1 | +#!/usr/bin/env python |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | +# |
| 4 | +# Copyright 2022 Stéphane Caron |
| 5 | +# |
| 6 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +# you may not use this file except in compliance with the License. |
| 8 | +# You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | + |
| 18 | +import logging |
| 19 | +import unittest |
| 20 | + |
| 21 | +from robot_descriptions._descriptions import DESCRIPTIONS |
| 22 | +from robot_descriptions.loaders.yourdfpy import load_robot_description |
| 23 | + |
| 24 | + |
| 25 | +class TestYourdfpy(unittest.TestCase): |
| 26 | + |
| 27 | + """ |
| 28 | + Check that all URDF descriptions are loaded properly in yourdfpy. |
| 29 | + """ |
| 30 | + |
| 31 | + def setUp(self): |
| 32 | + logging.basicConfig() |
| 33 | + logging.getLogger().setLevel(logging.INFO) |
| 34 | + |
| 35 | + @staticmethod |
| 36 | + def get_test_for_description(description: str): |
| 37 | + """ |
| 38 | + Get test function for a given description. |
| 39 | +
|
| 40 | + Args: |
| 41 | + description: Name of the description. |
| 42 | +
|
| 43 | + Returns: |
| 44 | + Test function for that description. |
| 45 | + """ |
| 46 | + |
| 47 | + def test(self): |
| 48 | + logging.info(f"Loading {description} in yourdfpy...") |
| 49 | + load_robot_description(description) |
| 50 | + |
| 51 | + return test |
| 52 | + |
| 53 | + |
| 54 | +for name, description in DESCRIPTIONS.items(): |
| 55 | + if description.has_urdf: |
| 56 | + setattr( |
| 57 | + TestYourdfpy, |
| 58 | + f"test_{name}", |
| 59 | + TestYourdfpy.get_test_for_description(name), |
| 60 | + ) |
0 commit comments