Skip to content

Commit a04008f

Browse files
committed
Little cleanup to VariableError tests and docs. robotframework#1869
Also enhanced docs about internally used exceptions a bit in general.
1 parent d6eb9fe commit a04008f

File tree

5 files changed

+35
-18
lines changed

5 files changed

+35
-18
lines changed

atest/robot/running/test_template.robot

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ Templates and timeouts
7070
Templates, timeouts, and for loops
7171
Check Test Case ${TESTNAME}
7272

73-
Templates and syntax errors
73+
Templated test ends after syntax errors
74+
Check Test Case ${TESTNAME}
75+
76+
Templated test continues after variable error
7477
Check Test Case ${TESTNAME}
7578

7679
Templates and fatal errors

atest/robot/standard_libraries/builtin/wait_until_keyword_succeeds.robot

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ Fail With Nonexisting Variable Inside Wait Until Keyword Succeeds
8888

8989
Pass With Initially Nonexisting Variable Inside Wait Until Keyword Succeeds
9090
${tc} = Check Test Case ${TESTNAME}
91-
Check Log Message ${tc.kws[0].kws[0].kws[0].msgs[0]} Variable '\${dynamically created variable}' not found. FAIL
91+
Check Log Message ${tc.kws[0].kws[0].kws[0].msgs[0]} Variable '\${created after accessing first time}' not found. FAIL
92+
Check Log Message ${tc.kws[0].kws[1].kws[0].msgs[0]} created in keyword teardown
9293
Length Should Be ${tc.kws[0].kws} 2
9394

9495
Variable Values Should Not Be Visible In Keyword Arguments

atest/testdata/running/test_template.robot

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,18 @@ Templates, timeouts, and for loops
168168
:FOR ${i} IN RANGE 10
169169
\ 0.05 seconds
170170

171-
Templates and syntax errors
171+
Templated test ends after syntax errors
172172
[Documentation] FAIL Keyword 'BuiltIn.Should Be Equal' expected 2 to 4 arguments, got 5.
173173
syntax error makes test end
174+
not compared anymore
175+
176+
Templated test continues after variable error
177+
[Documentation] FAIL Several failures occurred:\n\n
178+
... 1) Variable '\${this does not exist}' not found.\n\n
179+
... 2) compared and not equal != fails
180+
${this does not exist} ${this does not exist either}
181+
compared and equal compared and equal
182+
compared and not equal fails
174183

175184
Templates and fatal errors 1
176185
[Documentation] FAIL Several failures occurred:\n\n

atest/testdata/standard_libraries/builtin/wait_until_keyword_succeeds.robot

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,11 @@ Keyword Not Found Inside Wait Until Keyword Succeeds
105105
Wait Until Keyword Succeeds 1 second 0.1s Non Existing KW
106106

107107
Fail With Nonexisting Variable Inside Wait Until Keyword Succeeds
108-
[Documentation] FAIL GLOB:Keyword 'Get Length Nonexisting Variable' failed after retrying 3 times. * Variable '${nonexisting}' not found.
109-
Wait Until Keyword Succeeds 3 times 0s Get Length Nonexisting Variable
108+
[Documentation] FAIL GLOB:Keyword 'Access Nonexisting Variable' failed after retrying 3 times. * Variable '${nonexisting}' not found.
109+
Wait Until Keyword Succeeds 3 times 0s Access Nonexisting Variable
110110

111111
Pass With Initially Nonexisting Variable Inside Wait Until Keyword Succeeds
112-
Wait Until Keyword Succeeds 3 times 0s Get Length Initially Nonexisting Variable
113-
112+
Wait Until Keyword Succeeds 3 times 0s Access Initially Nonexisting Variable
114113

115114
*** Keywords ***
116115
User Keyword
@@ -124,11 +123,10 @@ Timeouted UK with Wait Until KW
124123
[Timeout] ${timeout}
125124
Wait Until Keyword Succeeds 100ms 10ms Fail Error in timeouted UK
126125

127-
Get Length Nonexisting Variable
128-
Get Length ${nonexisting}
126+
Access Nonexisting Variable
127+
Log ${nonexisting}
129128
Fail Should NEVER be executed
130129

131-
Get Length Initially Nonexisting Variable
132-
Get Length ${dynamically created variable}
133-
[Teardown] Set Test Variable ${dynamically created variable} dynamic_variable_value
134-
130+
Access Initially Nonexisting Variable
131+
Log ${created after accessing first time}
132+
[Teardown] Set Test Variable ${created after accessing first time} created in keyword teardown

src/robot/errors.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
"""Exceptions and return codes used internally.
16+
17+
External libraries should not used exceptions defined here.
18+
"""
19+
20+
1521
# Return codes from Robot and Rebot.
1622
# RC below 250 is the number of failed critical tests and exactly 250
1723
# means that number or more such failures.
@@ -48,13 +54,13 @@ class FrameworkError(RobotError):
4854
class DataError(RobotError):
4955
"""Used when the provided test data is invalid.
5056
51-
DataErrors are not be caught by keywords that run other keywords
52-
(e.g. `Run Keyword And Expect Error`). Libraries should thus use
53-
this exception with care.
57+
DataErrors are not caught by keywords that run other keywords
58+
(e.g. `Run Keyword And Expect Error`).
5459
"""
5560

61+
5662
class VariableError(DataError):
57-
"""Used when variable syntax or evaluation is invalid.
63+
"""Used when variable does not exist.
5864
5965
VariableErrors are caught by keywords that run other keywords
6066
(e.g. `Run Keyword And Expect Error`).
@@ -67,7 +73,7 @@ class TimeoutError(RobotError):
6773
This exception is handled specially so that execution of the
6874
current test is always stopped immediately and it is not caught by
6975
keywords executing other keywords (e.g. `Run Keyword And Expect
70-
Error`). Libraries should thus NOT use this exception themselves.
76+
Error`).
7177
"""
7278

7379

0 commit comments

Comments
 (0)