Revision: 3198
Author: pekka.klarck
Date: Wed May  5 15:02:22 2010
Log: Report syntax errors when setting variables correctly. Only tested with 'Run Kw And Expect/Ignore Error' because other keywords use the same exception attribute.
http://code.google.com/p/robotframework/source/detail?r=3198

Modified:
 /trunk/atest/robot/standard_libraries/builtin/run_keyword_with_errors.txt
/trunk/atest/testdata/standard_libraries/builtin/run_keyword_with_errors.txt
 /trunk/src/robot/running/keywords.py

=======================================
--- /trunk/atest/robot/standard_libraries/builtin/run_keyword_with_errors.txt Wed May 5 07:23:13 2010 +++ /trunk/atest/robot/standard_libraries/builtin/run_keyword_with_errors.txt Wed May 5 15:02:22 2010
@@ -47,6 +47,9 @@

 Ignore Error When Syntax Error At Run Time
     Check Test Case  ${TEST NAME}
+
+Ignore Error When Syntax Error In Setting Variables
+    Check Test Case  ${TEST NAME}

 Ignore Error When Syntax Error In For Loop
     Check Test Case  ${TEST NAME}
@@ -102,6 +105,9 @@

 Expect Error When Syntax Error At Run Time
     Check Test Case  ${TEST NAME}
+
+Expect Error When Syntax Error In Setting Variables
+    Check Test Case  ${TEST NAME}

 Expect Error When Syntax Error In For Loop
     Check Test Case  ${TEST NAME}
=======================================
--- /trunk/atest/testdata/standard_libraries/builtin/run_keyword_with_errors.txt Wed May 5 07:23:13 2010 +++ /trunk/atest/testdata/standard_libraries/builtin/run_keyword_with_errors.txt Wed May 5 15:02:22 2010
@@ -59,6 +59,11 @@
[Documentation] FAIL Keyword 'BuiltIn.No Operation' expected 0 arguments, got 4. Run Keyword And Ignore Error No Operation wrong number of arguments

+Ignore Error When Syntax Error In Setting Variables
+ [Documentation] FAIL Cannot assign return value of keyword 'BuiltIn.Set Variable' to variable '\...@{incompatible}': Expected list, got string instead
+    Run Keyword And Ignore Error  Invalid Syntax When Setting Variable
+
+
 Ignore Error When Syntax Error In For Loop
     [Documentation]  FAIL  Non-existing variable '\${nonex}'
     Run Keyword And Ignore Error  For Loop With Syntax Error
@@ -123,6 +128,10 @@
[Documentation] FAIL No keyword with name 'Non existing keyword' found.
     Run Keyword And Expect Error  *  Non existing keyword

+Expect Error When Syntax Error In Setting Variables
+ [Documentation] FAIL Cannot assign return value of keyword 'BuiltIn.Set Variable' to variable '\...@{incompatible}': Expected list, got string instead
+    Run Keyword And Expect Error  *  Invalid Syntax When Setting Variable
+
 Expect Error When Syntax Error In For Loop
     [Documentation]  FAIL  Non-existing variable '\${nonex}'
     Run Keyword And Expect Error  *  For Loop With Syntax Error
@@ -144,6 +153,9 @@
     [Timeout]  0.1 seconds
     Run Keyword And Ignore Error  Sleep  1 hour

+Invalid Syntax When Setting Variable
+    @{incompatible} =  Set Variable  string
+
 For Loop With Syntax Error
     :FOR  ${a}  IN  ${nonex}
     \   Whatever
=======================================
--- /trunk/src/robot/running/keywords.py        Wed May  5 09:40:19 2010
+++ /trunk/src/robot/running/keywords.py        Wed May  5 15:02:22 2010
@@ -121,9 +121,9 @@
         try:
             return self._run_and_set_variables(handler, output, namespace)
         except DataError, err:
-            msg = utils.unic(err)
+            msg = unicode(err)
             output.fail(msg)
-            raise ExecutionFailed(msg)
+            raise ExecutionFailed(msg, syntax=True)

     def _run_and_set_variables(self, handler, output, namespace):
         try:

Reply via email to