Skip to content

Commit

Permalink
Update main_tool.py
Browse files Browse the repository at this point in the history
make sure only required args exist in recipe, avoid adding an optional arg to all other recipes that would pass it as None
  • Loading branch information
sa3eed3ed authored Mar 11, 2024
1 parent 8bf31b8 commit 979db30
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions tests/cli/main_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down

0 comments on commit 979db30

Please sign in to comment.