From 2a053465fa6d29bd16beceb736ea65b9364def82 Mon Sep 17 00:00:00 2001 From: Samuel Gobbi Date: Wed, 25 Sep 2024 11:41:24 +0200 Subject: [PATCH] feature(interpreted functions): added checks in test_plan_validator to skip if no plan is available to test --- unified_planning/test/examples/minimals.py | 7 ++----- unified_planning/test/test_plan_validator.py | 7 +++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/unified_planning/test/examples/minimals.py b/unified_planning/test/examples/minimals.py index 5779b4c15..cd7f2caaa 100644 --- a/unified_planning/test/examples/minimals.py +++ b/unified_planning/test/examples/minimals.py @@ -605,7 +605,7 @@ def i_f_simple_bool(inputone, inputtwo): itwo = Fluent("itwo", IntType(0, 20)) instant_action_i_f_condition = InstantaneousAction("instant_action_i_f_condition") increase_val = InstantaneousAction("increase_val") - increase_val.add_effect(ione, Plus(ione, 2)) + increase_val.add_effect(itwo, Plus(itwo, 2)) instant_action_i_f_condition.add_precondition((funx(ione, itwo))) instant_action_i_f_condition.add_effect(end_goal, True) problem.add_fluent(end_goal) @@ -619,11 +619,8 @@ def i_f_simple_bool(inputone, inputtwo): problem.add_goal(end_goal) ifproblem = TestCase( problem=problem, - solvable=True, + solvable=False, # currently valid_plans=[ - up.plans.SequentialPlan([instant_action_i_f_condition()]), - ], - invalid_plans=[ up.plans.SequentialPlan([increase_val(), instant_action_i_f_condition()]), ], ) diff --git a/unified_planning/test/test_plan_validator.py b/unified_planning/test/test_plan_validator.py index fa703bd96..41a86214e 100644 --- a/unified_planning/test/test_plan_validator.py +++ b/unified_planning/test/test_plan_validator.py @@ -64,6 +64,11 @@ def test_all_from_factory(self): for p in self.problems.values(): if not pv.supports(p.problem.kind): continue + if not p.valid_plans: + print( + p.problem + ) # after adding an always impossible problem we have to make sure we skip it here + continue problem, plan = p.problem, p.valid_plans[0] validation_result = pv.validate(problem, plan) self.assertEqual(validation_result.status, ValidationResultStatus.VALID) @@ -72,6 +77,8 @@ def test_all_from_factory_with_problem_kind(self): for p in self.problems.values(): problem, plans = p.problem, p.valid_plans plan = plans[0] if plans else None + if not plan: # again skip the non existing plan + continue pk = problem.kind if SequentialPlanValidator.supports(pk): environment = unified_planning.environment.Environment()