diff --git a/tests/shard5/test_global_torque_driven_ocp.py b/tests/shard5/test_global_torque_driven_ocp.py index dd9d0e0be..4e9de0d95 100644 --- a/tests/shard5/test_global_torque_driven_ocp.py +++ b/tests/shard5/test_global_torque_driven_ocp.py @@ -487,7 +487,7 @@ def test_phase_transition_uneven_variable_number_by_bounds(phase_dynamics): @pytest.mark.parametrize("phase_dynamics", [PhaseDynamics.SHARED_DURING_THE_PHASE, PhaseDynamics.ONE_PER_NODE]) -def test_phase_transition_uneven_variable_number_by_mapping(phase_dynamics): +def test_phase_transition_uneven_variable_number_by_mapping(phase_dynamics, capsys): # Load phase_transition_uneven_variable_number_by_mapping from bioptim.examples.toy_examples.torque_driven_ocp import ( phase_transition_uneven_variable_number_by_mapping as ocp_module, @@ -508,6 +508,12 @@ def test_phase_transition_uneven_variable_number_by_mapping(phase_dynamics): ) sol = ocp.solve() + # Regression test for #712: cost evaluation must use each phase's own state layout. + sol.print_cost() + printed_cost = capsys.readouterr().out + assert "PHASE 0" in printed_cost + assert "PHASE 1" in printed_cost + # Check objective function value TestUtils.assert_objective_value(sol=sol, expected_value=-12397.11475053)