Skip to content

Commit

Permalink
Test that exact match wins over embedded matches regardless search or…
Browse files Browse the repository at this point in the history
…der.

To some extend related to #4454.
  • Loading branch information
pekkaklarck committed Sep 16, 2022
1 parent b1fbfa2 commit 63f06ea
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ Library Search Order Is Space Insensitive
Library Search Order Is Case Insensitive
Check Test Case ${TEST NAME}

Exact match wins over match containing embedded arguments regardless search order
Check Test Case ${TEST NAME}
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ Resource Search Order Is Case Insensitive

Default Resource Order Should Be Suite Specific
Check Test Case ${TEST NAME}

Exact match wins over match containing embedded arguments regardless search order
Check Test Case ${TEST NAME}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class TestLibrary:

def __init__(self, name='TestLibrary'):
self.name = name

def get_name(self):
return self.name

get_library_name = get_name

def no_operation(self):
raise AssertionError("No operation used in %s!" % self.name)
return self.name

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from robot.api.deco import keyword


@keyword('No ${Ope}ration')
def no_operation(ope):
raise AssertionError('Should not be run due to keywords with normal '
'arguments having higher precedence.')


@keyword('Get ${Name}')
def get_name(name):
raise AssertionError('Should not be run due to keywords with normal '
'arguments having higher precedence.')
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Library TestLibrary.py Library1 WITH NAME Library1
Library TestLibrary.py Library2 WITH NAME Library2
Library TestLibrary.py Library3 WITH NAME Library3
Library TestLibrary.py Library With Space WITH NAME Library With Space
Library embedded.py

*** Test Cases ***
Library Order Set In Suite Setup Should Be Available In Test Cases
Expand Down Expand Up @@ -43,7 +44,8 @@ Setting Library Order Returns Previous Library Order

Setting Library Order Allows Setting BuiltIn Library As Default Library
Set Library Search Order BuiltIn
No Operation
${result} = No Operation
Should Be Equal ${result} ${NONE}

Setting Library Order Allows Setting Own Library Before BuiltIn Library
Set Library Search Order Library1
Expand All @@ -61,12 +63,17 @@ Library Search Order Is Case Insensitive
Set Library Search Order library3 Library1
Active Library Should Be Library3

Exact match wins over match containing embedded arguments regardless search order
Set Library Search Order embedded Library1
Active Library Should Be Library1

*** Keywords ***
Active Library Should Be
[Arguments] ${expected}
${name} = Get Name
Should Be Equal ${name} ${expected}

Own Library Should Be Used
[Arguments] ${name}
Run Keyword And Expect Error No operation used in ${name}! No operation
[Arguments] ${expected}
${name} = No Operation
Should Be Equal ${name} ${expected}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*** Keywords ***
Get ${Name:\w+}
Fail Should not be run due to keywords with normal arguments having higher precedence
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*** Keywords ***
Get Name
[Return] resource1
RETURN resource1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Suite Setup Set Library Search Order resource1 resource2
Resource resource1.robot
Resource resource2.robot
Resource embedded.resource
Library ../set_library_search_order/TestLibrary.py
Library ../set_library_search_order/TestLibrary.py AnotherLibrary WITH NAME AnotherLibrary

Expand Down Expand Up @@ -57,6 +58,10 @@ Resource Search Order Is Case Insensitive
Set Library Search Order Resource1 resource2
Active Resource Should Be resource1

Exact match wins over match containing embedded arguments regardless search order
Set Library Search Order embedded resource1
Active Resource Should Be resource1

*** Keywords ***
Active Resource Should Be
[Arguments] ${expected}
Expand Down

0 comments on commit 63f06ea

Please sign in to comment.