From 979db307de3d5a130a6f2879e2e8a167f22a87a1 Mon Sep 17 00:00:00 2001 From: Said Eid <46205691+sa3eed3ed@users.noreply.github.com> Date: Mon, 11 Mar 2024 14:24:54 +0100 Subject: [PATCH] Update main_tool.py make sure only required args exist in recipe, avoid adding an optional arg to all other recipes that would pass it as None --- tests/cli/main_tool.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/cli/main_tool.py b/tests/cli/main_tool.py index 300dcbb5b..00b08b959 100644 --- a/tests/cli/main_tool.py +++ b/tests/cli/main_tool.py @@ -79,14 +79,19 @@ def testRecipeSetupArgs(self): runtime_name = module.get('runtime_name', module['name']) if runtime_name in self.tool.state._module_pool: setup_func = self.tool.state._module_pool[runtime_name].SetUp - expected_args = set(inspect.getfullargspec(setup_func).args) - expected_args.remove('self') + signature = inspect.signature(setup_func) + expected_positional_args = set([ + param.name + for param in signature.parameters.values() + if param.kind == param.POSITIONAL_ONLY + ]) provided_args = set(module['args']) - self.assertEqual( - expected_args, - provided_args, - f'Error in {recipe.name}:{runtime_name}') + self.assertTrue( + # Provided args include all positional args + expected_positional_args.issubset(provided_args), + f'Error in {recipe.name}:{runtime_name}', + ) def testRecipeValidators(self): """Tests that recipes do not specify invalid validators."""