Revision: 3705
Author: pekka.klarck
Date: Thu Jun  3 02:51:52 2010
Log: Fixed two bugs with test templates: 1) Assign mark (=) was removed at parsing time. Now that it is removed at run time, we could verify also that it is used only with the last variable (added FIXME about it). 2) Empty values were ignored. Now the keyword name on the parsing model (Step.keyword) can be None, which may need to be taken into account with RIDE.
http://code.google.com/p/robotframework/source/detail?r=3705

Modified:
 /trunk/atest/robot/keywords/return_values.txt
 /trunk/atest/robot/running/test_template.txt
 /trunk/atest/testdata/running/test_template.txt
 /trunk/src/robot/parsing/model.py
 /trunk/src/robot/running/keywords.py
 /trunk/utest/parsing/test_model.py

=======================================
--- /trunk/atest/robot/keywords/return_values.txt       Thu May 27 07:19:50 2010
+++ /trunk/atest/robot/keywords/return_values.txt       Thu Jun  3 02:51:52 2010
@@ -112,7 +112,7 @@

 No Keyword
     ${test} =  Check Test Case  ${TEST NAME}
-    Should Be Equal  ${test.kws[0].name}  \${nokeyword} =${SPACE}
+    Should Be Equal  ${test.kws[0].name}  \${nokeyword} = None

 Failing keyword
     ${test} =  Check Test Case  ${TEST NAME}
=======================================
--- /trunk/atest/robot/running/test_template.txt        Mon May 31 01:06:59 2010
+++ /trunk/atest/robot/running/test_template.txt        Thu Jun  3 02:51:52 2010
@@ -21,6 +21,12 @@

 Test Template With Variables And Keyword Name
     Check Test Case  ${TESTNAME}
+
+Test Template With Variable And Assign Mark (=)
+    Check Test Case  ${TESTNAME}
+
+Test Empty Values
+    Check Test Case  ${TESTNAME}

 Test Template With For
     Check Test Case  ${TESTNAME}
=======================================
--- /trunk/atest/testdata/running/test_template.txt     Mon May 31 01:06:59 2010
+++ /trunk/atest/testdata/running/test_template.txt     Thu Jun  3 02:51:52 2010
@@ -1,4 +1,5 @@
 *** Settings ***
+Documenation   NO RIDE because it would clean-up too much data.
 Test Template  Should Be Equal

 *** Variables ***
@@ -35,6 +36,18 @@
   [template]  Expect Exactly Three Args
   ${SAME VARIABLE}  Variable content  ${VARIABLE}

+Test Template With Variable And Assign Mark (=)
+  [Documentation]  FAIL  1= != 2=
+  [Template]  Expect Exactly Two Args
+  ${42} =     42 =
+  ${42}=      42=
+  ${1}=       ${2}=
+
+Test Empty Values
+  [Template]  Expect Exactly Two Args
+  \           \
+  ${EMPTY}    \
+
 Test Template With For
[Documentation] FAIL Several failures occurred:\n\n1) Templates not supported with FOR loops.\n\n2) Samething != Different
   Same  Same
@@ -55,7 +68,7 @@
     42  42

 Templates with Run Keyword
- [Documentation] FAIL Several failures occurred:\n\n1) First failure\n\n2) No keyword with name 'Variable content' found. + [Documentation] FAIL Several failures occurred:\n\n1) First failure\n\n2) No keyword with name 'Variable content =' found.
     [Template]  Run Keyword
     Should be equal  42  42
     Fail  First failure
=======================================
--- /trunk/src/robot/parsing/model.py   Wed Jun  2 00:43:18 2010
+++ /trunk/src/robot/parsing/model.py   Thu Jun  3 02:51:52 2010
@@ -490,15 +490,14 @@
         try:
             self.keyword = content[len(self.assign)]
         except IndexError:
-            self.keyword = ''
+            self.keyword = None
         self.args = content[len(self.assign)+1:]
         self.comment = comment

     def _get_assigned_vars(self, content):
         vars = []
         for item in content:
-            item = item.rstrip('= ')
-            if not is_var(item):
+            if not is_var(item.rstrip('= ')):
                 break
             vars.append(item)
         return vars
@@ -512,5 +511,5 @@
     def apply_template(self, template):
         if self.is_comment():
             return self
-        kw = [self.keyword] if self.keyword else []
+        kw = [self.keyword] if self.keyword is not None else []
         return Step([template] + self.assign + kw + self.args)
=======================================
--- /trunk/src/robot/running/keywords.py        Mon May 31 05:21:54 2010
+++ /trunk/src/robot/running/keywords.py        Thu Jun  3 02:51:52 2010
@@ -94,7 +94,8 @@
     def _get_name(self, handler_longname):
         if not self.assign:
             return handler_longname
-        return '%s = %s' % (', '.join(self.assign), handler_longname)
+        return '%s = %s' % (', '.join(a.rstrip('= ') for a in self.assign),
+                            handler_longname)

     def _run(self, handler, context):
         try:
@@ -144,6 +145,10 @@

     def _process_assign(self, assign):
         for var in assign:
+            # FIXME: Now that we need to remove '=' on the running side,
+            # we should also verify that it is only used with the last
+            # variable like in earlier versions.
+            var = var.rstrip('= ')
             if not is_var(var):
                 raise DataError('Invalid variable to assign: %s' % var)
             if self.list_var:
=======================================
--- /trunk/utest/parsing/test_model.py  Fri May 28 03:40:17 2010
+++ /trunk/utest/parsing/test_model.py  Thu Jun  3 02:51:52 2010
@@ -249,16 +249,16 @@

     def test_assign_to_one_var(self):
         self._test(['${var}', 'KW'], assign=['${var}'])
-        self._test(['${var}=', 'KW', 'a'], args=['a'], assign=['${var}'])
-        self._test(['@{var}     =', 'KW'], assign=['@{var}'])
+        self._test(['${var}=', 'KW', 'a'], args=['a'], assign=['${var}='])
+        self._test(['@{var}     =', 'KW'], assign=['@{var}     ='])

     def test_assign_to_multiple_var(self):
-        self._test(['${v1}', '${v2}', '@{v3} =', 'KW', '${a1}', '${a2}'],
- args=['${a1}', '${a2}'], assign=['${v1}', '${v2}', '@{v3}'])
-        self._test(['${v1}=', '${v2}=', 'KW'], assign=['${v1}', '${v2}'])
+        self._test(['${v1}', '${v2}', '@{v3}=', 'KW', '${a1}', '${a2}'],
+ args=['${a1}', '${a2}'], assign=['${v1}', '${v2}', '@{v3}=']) + self._test(['${v1}=', '${v2} =', 'KW'], assign=['${v1}=', '${v2} ='])

     def test_assign_without_keyword(self):
-        self._test(['${v1}', '${v2}'], kw='', assign=['${v1}', '${v2}'])
+        self._test(['${v1}', '${v2}'], kw=None, assign=['${v1}', '${v2}'])

     def test_is_comment(self):
         assert_true(Step([], comment="comment").is_comment())

Reply via email to