Skip to content

Commit a4e789a

Browse files
committed
[tests/python] Properly gate some tests using pytest.mark.skipif
[cmake] Remove some tests from list of Python tests depending on detected features
1 parent 4c5a80f commit a4e789a

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

tests/python/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ file(
1010
if(NOT BUILD_CROCODDYL_COMPAT)
1111
list(REMOVE_ITEM PYTHON_TESTS test_compat_croc.py)
1212
endif()
13-
if(NOT BUILD_WITH_PINOCCHIO_PYTHON_BINDINGS)
14-
list(REMOVE_ITEM PYTHON_TESTS test_constrained_dynamics.py)
13+
if(NOT BUILD_WITH_PINOCCHIO_SUPPORT)
14+
list(REMOVE_ITEM PYTHON_TESTS test_center_of_mass.py)
1515
list(REMOVE_ITEM PYTHON_TESTS test_frames.py)
16-
endif()
17-
if(NOT PINOCCHIO_V3)
16+
list(REMOVE_ITEM PYTHON_TESTS test_rollout.py)
17+
elseif(NOT PINOCCHIO_V3)
18+
# Pinocchio support, but not Pinocchio 3
1819
list(REMOVE_ITEM PYTHON_TESTS test_constrained_dynamics.py)
19-
list(REMOVE_ITEM PYTHON_TESTS test_frames.py)
2020
endif()
2121
make_directory(${CMAKE_CURRENT_BINARY_DIR})
2222

tests/python/test_continuous_dynamics.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
import numpy as np
77
import aligator
88
from aligator import dynamics, manifolds
9-
from pinocchio import Quaternion
9+
from eigenpy import Quaternion
1010
from utils import finite_diff, infNorm, create_multibody_ode
1111

1212
epsilon = 1e-6
1313
aligator.seed(42)
1414
np.random.seed(42)
15+
HAS_PINOCCHIO = aligator.has_pinocchio_features()
1516

1617

1718
class MyODE(dynamics.ODEAbstract):
@@ -71,6 +72,9 @@ def test_custom_ode():
7172
assert len(xs) == 11
7273

7374

75+
@pytest.mark.skipif(
76+
not HAS_PINOCCHIO, reason="Aligator was compiled without Pinocchio."
77+
)
7478
def test_multibody_free():
7579
ode = create_multibody_ode(True)
7680
if ode is None:
@@ -304,6 +308,9 @@ def test_continuous_centroidal_diff():
304308
assert np.allclose(Judiff, Ju0, epsilon), "err={}".format(infNorm(Judiff - Ju0))
305309

306310

311+
@pytest.mark.skipif(
312+
not HAS_PINOCCHIO, reason="Aligator was compiled without Pinocchio."
313+
)
307314
def test_kinodynamics():
308315
import pinocchio as pin
309316

@@ -337,6 +344,9 @@ def test_kinodynamics():
337344
ode.dForward(x0, u0, data)
338345

339346

347+
@pytest.mark.skipif(
348+
not HAS_PINOCCHIO, reason="Aligator was compiled without Pinocchio."
349+
)
340350
def test_kinodynamics_diff():
341351
import pinocchio as pin
342352

tests/python/test_finite_diff.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ def test_compute_jac_vs():
4242
assert np.allclose(fdata1.Jy, fdata1b.Jy, 1e-2)
4343

4444

45-
@pytest.mark.skipif(not HAS_PINOCCHIO, reason="Pinocchio bindings not present.")
45+
@pytest.mark.skipif(
46+
not HAS_PINOCCHIO, reason="Aligator was compiled without Pinocchio."
47+
)
4648
def test_compute_jac_multibody():
4749
model = pin.buildSampleModelHumanoid()
4850
space = manifolds.MultibodyConfiguration(model)
@@ -87,7 +89,6 @@ def test_compute_cost_se3():
8789

8890

8991
if __name__ == "__main__":
90-
import pytest
9192
import sys
9293

9394
sys.exit(pytest.main(sys.argv))

tests/python/test_frames.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""
2-
Test function related to frames.
2+
Test function related to Pinocchio frames.
3+
This test is not added to CTest when CMake does not detect Pinocchio.
34
"""
45

56
import aligator
@@ -194,4 +195,3 @@ def test_fly_high():
194195
import pytest
195196

196197
sys.exit(pytest.main(sys.argv))
197-
# test_frame_placement()

0 commit comments

Comments
 (0)