Source code for robot.running.invalidkeyword

#  Copyright 2008-2015 Nokia Networks
#  Copyright 2016-     Robot Framework Foundation
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  See the License for the specific language governing permissions and
#  limitations under the License.

from robot.errors import DataError
from robot.result import Keyword as KeywordResult
from robot.variables import VariableAssignment

from .arguments import EmbeddedArguments
from .model import Keyword as KeywordData
from .statusreporter import StatusReporter
from .keywordimplementation import KeywordImplementation

[docs] class InvalidKeyword(KeywordImplementation): """Represents an invalid keyword call. Keyword may not have been found, there could have been multiple matches, or the keyword call itself could have been invalid. """ type = KeywordImplementation.INVALID_KEYWORD def _get_embedded(self, name) -> 'EmbeddedArguments|None': try: return super()._get_embedded(name) except DataError: return None
[docs] def create_runner(self, name, languages=None): return InvalidKeywordRunner(self, name)
[docs] def bind(self, data: KeywordData) -> 'InvalidKeyword': return self.copy(parent=data.parent)
[docs] class InvalidKeywordRunner: def __init__(self, keyword: InvalidKeyword, name: 'str|None' = None): self.keyword = keyword = name or if not keyword.error: raise ValueError("Executed 'InvalidKeyword' instance requires 'error'.")
[docs] def run(self, data: KeywordData, result: KeywordResult, context, run=True): kw = self.keyword.bind(data) result.config(, if kw.owner else None, args=data.args, assign=tuple(VariableAssignment(data.assign)), type=data.type) with StatusReporter(data, result, context, run, implementation=kw): # 'error' is can be set to 'None' by a listener that handles it. if run and kw.error is not None: raise DataError(kw.error)
dry_run = run