diff --git a/atest/robot/keywords/optional_given_when_then.robot b/atest/robot/keywords/optional_given_when_then.robot index 3fc6b6b878e..88784053514 100644 --- a/atest/robot/keywords/optional_given_when_then.robot +++ b/atest/robot/keywords/optional_given_when_then.robot @@ -46,7 +46,7 @@ Keyword can be used with and without prefix Should Be Equal ${tc.kws[5].name} Then we are in Berlin city Should Be Equal ${tc.kws[6].name} we are in Berlin city -In user keyword name with normal arguments and localized prefixes +Localized prefixes ${tc} = Check Test Case ${TEST NAME} Should Be Equal ${tc.kws[0].name} Oletetaan we don't drink too many beers Should Be Equal ${tc.kws[1].name} Kun we are in @@ -55,5 +55,15 @@ In user keyword name with normal arguments and localized prefixes Should Be Equal ${tc.kws[4].name} Niin we get this feature ready today Should Be Equal ${tc.kws[5].name} ja we don't drink too many beers +Prefix consisting of multiple words + ${tc} = Check Test Case ${TEST NAME} + Should Be Equal ${tc.kws[0].name} Étant donné multipart prefixes didn't work with RF 6.0 + Should Be Equal ${tc.kws[1].name} Zakładając, że multipart prefixes didn't work with RF 6.0 + Should Be Equal ${tc.kws[2].name} Diyelim ki multipart prefixes didn't work with RF 6.0 + Should Be Equal ${tc.kws[3].name} Eğer ki multipart prefixes didn't work with RF 6.0 + Should Be Equal ${tc.kws[4].name} O zaman multipart prefixes didn't work with RF 6.0 + Should Be Equal ${tc.kws[5].name} В случай че multipart prefixes didn't work with RF 6.0 + Should Be Equal ${tc.kws[6].name} Fie ca multipart prefixes didn't work with RF 6.0 + Prefix must be followed by space Check Test Case ${TEST NAME} diff --git a/atest/testdata/keywords/optional_given_when_then.robot b/atest/testdata/keywords/optional_given_when_then.robot index b5afa8f374b..16358241249 100644 --- a/atest/testdata/keywords/optional_given_when_then.robot +++ b/atest/testdata/keywords/optional_given_when_then.robot @@ -1,3 +1,9 @@ +Language: French +Language: Polish +Language: Turkish +Language: Bulgarian +Language: Romanian + *** Settings *** Resource resources/optional_given_when_then.robot @@ -42,7 +48,7 @@ Keyword can be used with and without prefix Then we are in Berlin city we are in Berlin city -In user keyword name with normal arguments and localized prefixes +Localized prefixes Oletetaan we don't drink too many beers Kun we are in museum cafe mutta we don't drink too many beers @@ -50,13 +56,21 @@ In user keyword name with normal arguments and localized prefixes Niin we get this feature ready today ja we don't drink too many beers +Prefix consisting of multiple words + Étant donné multipart prefixes didn't work with RF 6.0 + Zakładając, że multipart prefixes didn't work with RF 6.0 + Diyelim ki multipart prefixes didn't work with RF 6.0 + Eğer ki multipart prefixes didn't work with RF 6.0 + O zaman multipart prefixes didn't work with RF 6.0 + В случай че multipart prefixes didn't work with RF 6.0 + Fie ca multipart prefixes didn't work with RF 6.0 + Prefix must be followed by space [Documentation] FAIL ... No keyword with name 'Givenwe don't drink too many beers' found. Did you mean: ... ${SPACE*4}We Don't Drink Too Many Beers Givenwe don't drink too many beers - *** Keywords *** We don't drink too many beers No Operation @@ -83,3 +97,6 @@ We ${x} This ${thing} Implemented We Go To ${somewhere} Should Be Equal ${somewhere} walking tour + +Multipart prefixes didn't work with RF 6.0 + No Operation diff --git a/src/robot/running/namespace.py b/src/robot/running/namespace.py index bce60e2f82c..1467ef3a350 100644 --- a/src/robot/running/namespace.py +++ b/src/robot/running/namespace.py @@ -295,20 +295,19 @@ def _get_runner(self, name): if not runner: runner = self._get_implicit_runner(name) if not runner: - runner = self._get_bdd_style_runner(name) + runner = self._get_bdd_style_runner(name, self.languages.bdd_prefixes) return runner - def _get_bdd_style_runner(self, name): - parts = name.split(maxsplit=1) - if len(parts) < 2: - return None - prefix, keyword = parts - if prefix.title() in self.languages.bdd_prefixes: - runner = self._get_runner(keyword) - if runner: - runner = copy.copy(runner) - runner.name = name - return runner + def _get_bdd_style_runner(self, name, prefixes): + parts = name.split() + for index in range(1, len(parts)): + prefix = ' '.join(parts[:index]).title() + if prefix in prefixes: + runner = self._get_runner(' '.join(parts[index:])) + if runner: + runner = copy.copy(runner) + runner.name = name + return runner return None def _get_implicit_runner(self, name):