Skip to content

Commit c354f30

Browse files
stephane-caronStéphane Caron
authored andcommitted
Clear out try-imports in loader test fixtures
1 parent 8f75857 commit c354f30

File tree

5 files changed

+57
-67
lines changed

5 files changed

+57
-67
lines changed

tests/loaders/test_pinocchio.py

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,41 @@
2020

2121
from robot_descriptions._descriptions import DESCRIPTIONS
2222

23-
try:
24-
from robot_descriptions.loaders.pinocchio import load_robot_description
23+
from robot_descriptions.loaders.pinocchio import load_robot_description
2524

26-
class TestPinocchio(unittest.TestCase):
25+
class TestPinocchio(unittest.TestCase):
2726

28-
"""
29-
Check that all descriptions are loaded properly in Pinocchio.
30-
"""
31-
32-
def setUp(self):
33-
logging.basicConfig()
34-
logging.getLogger().setLevel(logging.INFO)
27+
"""
28+
Check that all descriptions are loaded properly in Pinocchio.
29+
"""
3530

36-
@staticmethod
37-
def get_test_for_description(description: str):
38-
"""
39-
Get test function for a given description.
31+
def setUp(self):
32+
logging.basicConfig()
33+
logging.getLogger().setLevel(logging.INFO)
4034

41-
Args:
42-
description: Name of the description.
43-
44-
Returns:
45-
Test function for that description.
46-
"""
35+
@staticmethod
36+
def get_test_for_description(description: str):
37+
"""
38+
Get test function for a given description.
4739
48-
def test(self):
49-
logging.info(f"Loading {description} in Pinocchio...")
50-
load_robot_description(description)
40+
Args:
41+
description: Name of the description.
5142
52-
return test
43+
Returns:
44+
Test function for that description.
45+
"""
5346

54-
# Add a test function for each URDF description
55-
for name, description in DESCRIPTIONS.items():
56-
if description.has_urdf:
57-
setattr(
58-
TestPinocchio,
59-
f"test_{name}",
60-
TestPinocchio.get_test_for_description(name),
61-
)
47+
def test(self):
48+
logging.info(f"Loading {description} in Pinocchio...")
49+
load_robot_description(description)
6250

63-
except ImportError:
51+
return test
6452

65-
pass
53+
# Add a test function for each URDF description
54+
for name, description in DESCRIPTIONS.items():
55+
if description.has_urdf:
56+
setattr(
57+
TestPinocchio,
58+
f"test_{name}",
59+
TestPinocchio.get_test_for_description(name),
60+
)

tests/loaders/test_pybullet.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import pybullet
2222

2323
from robot_descriptions._descriptions import DESCRIPTIONS
24+
2425
from robot_descriptions.loaders.pybullet import load_robot_description
2526

2627

tests/loaders/test_robomeshcat.py

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,36 @@
1717

1818
import unittest
1919

20-
try:
21-
from robot_descriptions.loaders.robomeshcat import load_robot_description
20+
from robot_descriptions.loaders.robomeshcat import load_robot_description
2221

23-
class TestRoboMeshCat(unittest.TestCase):
2422

25-
"""
26-
Check that all descriptions are loaded properly in RoboMeshCat.
27-
28-
Since RoboMeshCat relies on Pinocchio, we only test it on a couple of
29-
robot descriptions.
30-
"""
23+
class TestRoboMeshCat(unittest.TestCase):
3124

32-
def test_load_robot_description(self):
33-
"""
34-
Load a robot description with RoboMeshCat.
25+
"""
26+
Check that all descriptions are loaded properly in RoboMeshCat.
3527
36-
"""
37-
mini_cheetah = load_robot_description("mini_cheetah_description")
38-
self.assertIsNotNone(mini_cheetah)
28+
Since RoboMeshCat relies on Pinocchio, we only test it on a couple of
29+
robot descriptions.
30+
"""
3931

40-
# def test_description_with_cylinders(self):
41-
# """
42-
# Load a robot description with cylinder shapes.
43-
# """
44-
# upkie = load_robot_description("upkie_description")
45-
# self.assertIsNotNone(upkie)
46-
47-
def test_collada_description(self):
48-
"""
49-
Test a robot description with Collada meshes.
50-
"""
51-
r2 = load_robot_description("r2_description")
52-
self.assertIsNotNone(r2)
32+
def test_load_robot_description(self):
33+
"""
34+
Load a robot description with RoboMeshCat.
5335
36+
"""
37+
mini_cheetah = load_robot_description("mini_cheetah_description")
38+
self.assertIsNotNone(mini_cheetah)
5439

55-
except ImportError:
40+
def test_description_with_cylinders(self):
41+
"""
42+
Load a robot description with cylinder shapes.
43+
"""
44+
upkie = load_robot_description("upkie_description")
45+
self.assertIsNotNone(upkie)
5646

57-
pass
47+
def test_collada_description(self):
48+
"""
49+
Test a robot description with Collada meshes.
50+
"""
51+
r2 = load_robot_description("r2_description")
52+
self.assertIsNotNone(r2)

tests/loaders/test_yourdfpy.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import unittest
2020

2121
from robot_descriptions._descriptions import DESCRIPTIONS
22-
from robot_descriptions.loaders.yourdfpy import load_robot_description
2322

23+
from robot_descriptions.loaders.yourdfpy import load_robot_description
2424

2525
class TestYourdfpy(unittest.TestCase):
2626

@@ -50,7 +50,6 @@ def test(self):
5050

5151
return test
5252

53-
5453
for name, description in DESCRIPTIONS.items():
5554
if description.has_urdf:
5655
setattr(

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tox]
22
isolated_build = True
3-
envlist = py{37, 38, 39, 310}
3+
envlist = py{37,38,39,310}-{mujoco,pinocchio,pybullet,robomeshcat,yourdfpy}
44

55
[gh-actions]
66
python =

0 commit comments

Comments
 (0)