Skip to content

Commit 39b39d4

Browse files
CICD: Isolate loader tests in submodules
Merge remaining loader tests to the description test fixture.
1 parent 1361dc4 commit 39b39d4

File tree

11 files changed

+91
-118
lines changed

11 files changed

+91
-118
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ All notable changes to this project will be documented in this file.
4949

5050
### Changed
5151

52+
- CICD: Isolate loader tests in testing submodules
5253
- CICD: Update checkout actions to v4
5354
- Update MuJoCo Menagerie repository commit
5455
- Update eDO description repository

tests/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77
from .test_clone_to_cache import TestCloneToCache
88
from .test_clone_to_directory import TestCloneToDirectory
99
from .test_descriptions import TestDescriptions
10-
from .test_loaders import TestLoaders
1110
from .test_progress_bar import TestProgressBar
1211

1312
__all__ = [
1413
"TestCloneToCache",
1514
"TestCloneToDirectory",
1615
"TestDescriptions",
17-
"TestLoaders",
1816
"TestProgressBar",
1917
]

tests/loaders/test_idyntree.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,24 @@
77
import unittest
88

99
from robot_descriptions._descriptions import DESCRIPTIONS
10+
from robot_descriptions.loaders.idyntree import (
11+
load_robot_description as load_idyntree,
12+
)
1013

11-
from robot_descriptions.loaders.idyntree import load_robot_description
1214

1315
class TestiDynTree(unittest.TestCase):
14-
1516
"""
1617
Check that all descriptions are loaded properly in iDynTree.
1718
"""
1819

20+
def test_idyntree(self):
21+
self.assertIsNotNone(
22+
load_idyntree(
23+
"upkie_description",
24+
commit="98502d5b175c3d6b60b3cf475b7eeef9fd290c43",
25+
)
26+
)
27+
1928
@staticmethod
2029
def get_test_for_description(description: str):
2130
"""
@@ -29,10 +38,11 @@ def get_test_for_description(description: str):
2938
"""
3039

3140
def test(self):
32-
load_robot_description(description)
41+
load_idyntree(description)
3342

3443
return test
3544

45+
3646
# Add a test function for each URDF description
3747
for name, description in DESCRIPTIONS.items():
3848
if description.has_urdf:

tests/loaders/test_mujoco.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@
77
import unittest
88

99
from robot_descriptions._descriptions import DESCRIPTIONS
10-
from robot_descriptions.loaders.mujoco import load_robot_description
10+
from robot_descriptions.loaders.mujoco import (
11+
load_robot_description as load_mujoco,
12+
)
1113

1214

1315
class TestMuJoCo(unittest.TestCase):
14-
1516
"""
1617
Check that all MJCF descriptions are loaded properly in MuJoCo.
1718
"""
1819

20+
def test_mujoco(self):
21+
self.assertIsNotNone(load_mujoco("cassie_mj_description"))
22+
1923
@staticmethod
2024
def get_test_for_description(description: str):
2125
"""
@@ -29,7 +33,7 @@ def get_test_for_description(description: str):
2933
"""
3034

3135
def test(self):
32-
load_robot_description(description)
36+
load_mujoco(description)
3337

3438
return test
3539

tests/loaders/test_pinocchio.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,24 @@
77
import unittest
88

99
from robot_descriptions._descriptions import DESCRIPTIONS
10-
from robot_descriptions.loaders.pinocchio import load_robot_description
10+
from robot_descriptions.loaders.pinocchio import (
11+
load_robot_description as load_pinocchio,
12+
)
1113

1214

1315
class TestPinocchio(unittest.TestCase):
1416
"""
1517
Check that all descriptions are loaded properly in Pinocchio.
1618
"""
1719

20+
def test_pinocchio(self):
21+
self.assertIsNotNone(
22+
load_pinocchio(
23+
"upkie_description",
24+
commit="98502d5b175c3d6b60b3cf475b7eeef9fd290c43",
25+
)
26+
)
27+
1828
@staticmethod
1929
def get_test_for_description(description: str):
2030
"""
@@ -28,7 +38,7 @@ def get_test_for_description(description: str):
2838
"""
2939

3040
def test(self):
31-
load_robot_description(description)
41+
load_pinocchio(description)
3242

3343
return test
3444

tests/loaders/test_pybullet.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
import pybullet
1010

1111
from robot_descriptions._descriptions import DESCRIPTIONS
12-
13-
from robot_descriptions.loaders.pybullet import load_robot_description
12+
from robot_descriptions.loaders.pybullet import (
13+
load_robot_description as load_pybullet,
14+
)
1415

1516

1617
class TestPyBullet(unittest.TestCase):
17-
1818
"""
1919
Check that all descriptions are loaded properly in PyBullet.
2020
"""
@@ -31,12 +31,22 @@ def tearDown(self):
3131
"""
3232
pybullet.disconnect()
3333

34+
def test_pybullet(self):
35+
pybullet.connect(pybullet.DIRECT)
36+
self.assertIsNotNone(
37+
load_pybullet(
38+
"upkie_description",
39+
commit="98502d5b175c3d6b60b3cf475b7eeef9fd290c43",
40+
)
41+
)
42+
pybullet.disconnect()
43+
3444
def test_value_error_when_no_urdf(self):
3545
"""
3646
Test exception raised when a description has no URDF_PATH.
3747
"""
3848
with self.assertRaises(ValueError):
39-
load_robot_description("_empty_description")
49+
load_pybullet("_empty_description")
4050

4151
@staticmethod
4252
def get_test_for_description(description: str):
@@ -51,7 +61,7 @@ def get_test_for_description(description: str):
5161
"""
5262

5363
def test(self):
54-
load_robot_description(description)
64+
load_pybullet(description)
5565

5666
return test
5767

tests/loaders/test_robomeshcat.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,24 @@
77
import unittest
88

99
from robot_descriptions._descriptions import DESCRIPTIONS
10-
from robot_descriptions.loaders.robomeshcat import load_robot_description
10+
from robot_descriptions.loaders.robomeshcat import (
11+
load_robot_description as load_robomeshcat,
12+
)
1113

1214

1315
class TestRoboMeshCat(unittest.TestCase):
14-
1516
"""
1617
Check that all descriptions are loaded properly in RoboMeshCat.
1718
"""
1819

20+
def test_robomeshcat(self):
21+
self.assertIsNotNone(
22+
load_robomeshcat(
23+
"upkie_description",
24+
commit="98502d5b175c3d6b60b3cf475b7eeef9fd290c43",
25+
)
26+
)
27+
1928
@staticmethod
2029
def get_test_for_description(description: str):
2130
"""
@@ -29,7 +38,7 @@ def get_test_for_description(description: str):
2938
"""
3039

3140
def test(self):
32-
load_robot_description(description)
41+
load_robomeshcat(description)
3342

3443
return test
3544

tests/loaders/test_yourdfpy.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,24 @@
77
import unittest
88

99
from robot_descriptions._descriptions import DESCRIPTIONS
10-
from robot_descriptions.loaders.yourdfpy import load_robot_description
10+
from robot_descriptions.loaders.yourdfpy import (
11+
load_robot_description as load_yourdfpy,
12+
)
1113

1214

1315
class TestYourdfpy(unittest.TestCase):
14-
1516
"""
1617
Check that all URDF descriptions are loaded properly in yourdfpy.
1718
"""
1819

20+
def test_yourdfpy(self):
21+
self.assertIsNotNone(
22+
load_yourdfpy(
23+
"upkie_description",
24+
commit="98502d5b175c3d6b60b3cf475b7eeef9fd290c43",
25+
)
26+
)
27+
1928
@staticmethod
2029
def get_test_for_description(description: str):
2130
"""
@@ -29,7 +38,7 @@ def get_test_for_description(description: str):
2938
"""
3039

3140
def test(self):
32-
load_robot_description(description)
41+
load_yourdfpy(description)
3342

3443
return test
3544

tests/test_descriptions.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
import git
1313

1414
from robot_descriptions._descriptions import DESCRIPTIONS
15+
from robot_descriptions.loaders.pinocchio import (
16+
load_robot_description as load_pinocchio,
17+
)
1518

1619

1720
class TestDescriptions(unittest.TestCase):
@@ -46,6 +49,13 @@ def test_all_descriptions(self):
4649
f"in {description}",
4750
)
4851

52+
def test_cache_path_package_name(self):
53+
"""Check a description with package:// URIs and a custom commit ID."""
54+
load_pinocchio(
55+
"draco3_description",
56+
commit="5afd19733d7b3e9f1135ba93e0aad90ed1a24cc7",
57+
)
58+
4959
def test_invalid_description_commit(self):
5060
invalid_commit = "foobar"
5161
os.environ["ROBOT_DESCRIPTION_COMMIT"] = invalid_commit
@@ -55,3 +65,11 @@ def test_invalid_description_commit(self):
5565
if description_name in sys.modules:
5666
del sys.modules[description_name]
5767
import_module(description_name)
68+
69+
def test_load_with_commit_then_without(self):
70+
# https://github.com/robot-descriptions/robot_descriptions.py/issues/67
71+
load_pinocchio(
72+
"draco3_description",
73+
commit="5afd19733d7b3e9f1135ba93e0aad90ed1a24cc7",
74+
)
75+
load_pinocchio("baxter_description")

tests/test_loaders.py

Lines changed: 0 additions & 96 deletions
This file was deleted.

0 commit comments

Comments
 (0)