File tree Expand file tree Collapse file tree 4 files changed +78
-5
lines changed
Expand file tree Collapse file tree 4 files changed +78
-5
lines changed Original file line number Diff line number Diff line change @@ -61,10 +61,21 @@ User Keyword Name Ending With Dot
6161 Check Test And Three Keyword Names User Keyword Name Ending With Dot User Keyword.
6262
6363Name Set Using 'robot_name' Attribute
64- Check Test Case ${TESTNAME }
64+ ${tc } = Check Test Case ${TESTNAME }
65+ Check Log Message ${tc.kws[0].msgs[0] } My name was set using 'robot_name' attribute!
66+
67+ Name Set Using 'robot.api.deco.keyword' Decorator
68+ ${tc } = Check Test Case ${TESTNAME }
69+ Check Log Message ${tc.kws[0].msgs[0] } My name was set using 'robot.api.deco.keyword' decorator!
70+
71+ Custom non-ASCII name
72+ Check Test Case ${TESTNAME }
6573
6674Old Name Doesn't Work If Name Set Using 'robot_name'
67- Check Test Case ${TESTNAME }
75+ Check Test Case ${TESTNAME }
76+
77+ Keyword can just be marked without changing its name
78+ Check Test Case ${TESTNAME }
6879
6980*** Keywords ***
7081Check Test And Three Keyword Names
Original file line number Diff line number Diff line change @@ -52,12 +52,22 @@ User Keyword Name Ending With Dot
5252 _US_er_ K EY_word .
5353
5454Name Set Using 'robot_name' Attribute
55- Name Set Using Robot Name Attribute
55+ Name set using 'robot_name' attribute
56+
57+ Name Set Using 'robot.api.deco.keyword' decorator
58+ Name set using 'robot.api.deco.keyword' decorator
59+
60+ Custom non-ASCII name
61+ Custom nön-ÄSCII name
5662
5763Old Name Doesn't Work If Name Set Using 'robot_name'
5864 [Documentation] FAIL No keyword with name 'Name Set In Method Signature' found.
5965 Name Set In Method Signature
6066
67+ Keyword can just be marked without changing its name
68+ No Custom Name Given 1
69+ No Custom Name Given 2
70+
6171*** Keywords ***
6272Keyword Only In Test Case File
6373 Log Keyword from test case file
Original file line number Diff line number Diff line change 1- from robot .api import deco
1+ # coding=UTF-8
2+
3+ from robot .api .deco import keyword
4+
25
36class MyLibrary1 :
47
@@ -29,6 +32,23 @@ def copy_directory(self):
2932 def no_operation (self ):
3033 print "Overrides keyword from BuiltIn library"
3134
32- @deco .keyword ('Name Set Using Robot Name Attribute' )
35+ def method (self ):
36+ print "My name was set using 'robot_name' attribute!"
37+
38+ method .robot_name = "Name set using 'robot_name' attribute"
39+
40+ @keyword ("Name set using 'robot.api.deco.keyword' decorator" )
3341 def name_set_in_method_signature (self ):
42+ print "My name was set using 'robot.api.deco.keyword' decorator!"
43+
44+ @keyword (name = u'Custom nön-ÄSCII name' )
45+ def non_ascii_would_not_work_here (self ):
46+ pass
47+
48+ @keyword ()
49+ def no_custom_name_given_1 (self ):
50+ pass
51+
52+ @keyword
53+ def no_custom_name_given_2 (self ):
3454 pass
Original file line number Diff line number Diff line change 1+ import unittest
2+
3+ from robot .api .deco import keyword
4+ from robot .utils .asserts import assert_equals
5+
6+
7+ class TestKeywordName (unittest .TestCase ):
8+
9+ def test_give_name_to_function (self ):
10+ @keyword ('Given name' )
11+ def func ():
12+ pass
13+ assert_equals (func .robot_name , 'Given name' )
14+
15+ def test_give_name_to_method (self ):
16+ class Class :
17+ @keyword ('Given name' )
18+ def method (self ):
19+ pass
20+ assert_equals (Class .method .robot_name , 'Given name' )
21+
22+ def test_no_name (self ):
23+ @keyword ()
24+ def func ():
25+ pass
26+ assert_equals (func .robot_name , None )
27+
28+ def test_no_name_nor_parens (self ):
29+ @keyword
30+ def func ():
31+ pass
32+ assert_equals (func .robot_name , None )
You can’t perform that action at this time.
0 commit comments