Skip to content

Fail the Dryrun when keyword not found (embedded arguments, argument as keyword name) #5231

Closed as not planned

Description

@Abhiramborige

Hii @pekkaklarck , thanks for the framework support. I got a small issue in the usage of embedded arguments. I request to please help me out.

In python file:

class Temp:
    def __init__(self):
        self.valid_methods = ['call_func1', 'call_func2']
        
    @keyword('${function_name}', types=[str])
    def process_call(self, function_name, *args, **kwargs):
         if function_name not in self.valid_methods:
                raise KeywordError(f"Keyword '{function_name}' not found.")
        print(function_name)

In robot file:

*** Settings ***
Library            Temp.py
*** Test Cases ***
[Demo1]
    Call_func1            123      123
[Demo2]
    blahblah           

When I execute normally, Demo2 gets failed. But when I use the dryrun option, even though "blahblah" keyword is not to be expected as a keyword, Demo2 is pass.
I want the list of valid_methods to be treated as valid methods along with parameter check in the dryrun, so that "blahblah" usage is detected as wrong usage and fails the dryrun.

Activity

  1. changed the title [-]Fail the Dryrun when keyword not found ?[/-] [+]Fail the Dryrun when keyword not found (embedded arguments, argument as keyword name)[/+] on Oct 9, 2024
  2. Abhiramborige commented on Oct 9, 2024

    @Abhiramborige
    Author

    Is there any easy way to extract all keywords used in robot file and validate with the self.valid_methods list ?
    That would be really helpful in case of dry run.

  3. pekkaklarck commented on Oct 18, 2024

    @pekkaklarck
    Member

    Keywords aren't run in the dry-run mode so that's why your explicit check isn't executed. If you know the keyword names beforehand, as it seems, you can construct the keyword name so that only the specified keyword will match:

    @keyword('${name:call_func1|call_func2}')
    def _(name, *args):
        print(name, 'called with', args)

    The problem with the above is that if the you use the keyword in different case like Call_func1 instead of call_func1, you'll get a warning about that. That could be avoided by making the match case-insensitive by prefixing the pattern with a (?i) group, but at the moment Robot doesn't allow any regexp extensions like that. That limitation could be lifted, though, and I'll submit a separate issue about it.

    If you have further questions, please use our Slack or Forum. This issue tracker is for bug reports and enhancement requests.

  4. Abhiramborige commented on Oct 18, 2024

    @Abhiramborige
    Author

    @pekkaklarck thanks for that!. It was helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions