5 new revisions:

Revision: 14ffec23d596
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Fri May 10 04:22:40 2013
Log: More tests for delayed resolving of variables in variable table....
http://code.google.com/p/robotframework/source/detail?r=14ffec23d596

Revision: 6bf5f7e3415a
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Fri May 10 04:32:46 2013
Log:      Refactored delayed resolving of variables in variable table....
http://code.google.com/p/robotframework/source/detail?r=6bf5f7e3415a

Revision: b8a889e56dbc
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Fri May 10 04:34:26 2013
Log: UG: Fixed example related to using Java classes as variable files and ...
http://code.google.com/p/robotframework/source/detail?r=b8a889e56dbc

Revision: 5676a5318d0e
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Fri May 10 04:34:38 2013
Log:      regen
http://code.google.com/p/robotframework/source/detail?r=5676a5318d0e

Revision: 8b2d981e429f
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Fri May 10 04:34:48 2013
Log:      Automated merge with https://robotframework.googlecode.com/hg/
http://code.google.com/p/robotframework/source/detail?r=8b2d981e429f

==============================================================================
Revision: 14ffec23d596
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Fri May 10 04:22:40 2013
Log:      More tests for delayed resolving of variables in variable table.

Update issue 561
Cc: pekka.klarck
Added some more tests. For example, using variables from variable files in
delayed manner and using already delayed value in variable table. The current
implementation already handled all these cases.
http://code.google.com/p/robotframework/source/detail?r=14ffec23d596

Modified:
 /atest/robot/variables/variables_from_resource_files.txt
 /atest/robot/variables/variables_from_variable_files.txt
 /atest/testdata/variables/resvarfiles/resource.txt
 /atest/testdata/variables/resvarfiles/resource_2.txt
 /atest/testdata/variables/variables_from_resource_files.txt
 /atest/testdata/variables/variables_from_variable_files.txt

=======================================
--- /atest/robot/variables/variables_from_resource_files.txt Thu Mar 14 03:49:04 2013 +++ /atest/robot/variables/variables_from_resource_files.txt Fri May 10 04:22:40 2013
@@ -12,9 +12,6 @@

 Scalar String With Escapes
     Check Test Case    ${TEST NAME}
-
-Resolving Local Variable Defined From Resource File
-    Check Test Case    ${TEST NAME}

 Empty Scalar String
     Check Test Case    ${TEST NAME}
@@ -60,3 +57,9 @@

 Assign Mark With List variable
     Check Test Case    ${TEST NAME}
+
+Variables From Resource Files Can Be Used In Local Variable Table
+    Check Test Case    ${TEST NAME}
+
+Imported Resource Can Use Variables From Resources It Imports In Its Variable Table
+    Check Test Case    ${TEST NAME}
=======================================
--- /atest/robot/variables/variables_from_variable_files.txt Fri Aug 31 03:43:31 2012 +++ /atest/robot/variables/variables_from_variable_files.txt Fri May 10 04:22:40 2013
@@ -51,3 +51,6 @@

 Variable Names Are Underscore Insensitive
     Check Test Case    ${TEST NAME}
+
+Variables From Variable Files Can Be Used In Local Variable Table
+    Check Test Case    ${TEST NAME}
=======================================
--- /atest/testdata/variables/resvarfiles/resource.txt Wed Mar 20 06:34:45 2013 +++ /atest/testdata/variables/resvarfiles/resource.txt Fri May 10 04:22:40 2013
@@ -21,9 +21,11 @@
 @{s P a c es }    Variable name with spaces
 ${UNDER_scores}    Variable name with under scores
 @{_u_n_d_e_r___s_c_o_r_e_s_}    Variable name with under scores
-${ASSING MARK}    This syntax works starting from 1.8
-@{ASSIGN MARK}    This syntax works    starting    from    ${1.8}
+${ASSIGN MARK} =   This syntax works starting from 1.8
+@{ASSIGN MARK} =   This syntax works    starting    from    ${1.8}
 ${PRIORITIES 1}    Resource File
 ${PRIORITIES 2}    Resource File
 ${PRIORITIES 3}    Resource File
 ${PRIORITIES 4}    Resource File
+${DEFINITION IN SAME RESOURCE}    ${PRIORITIES 4}
+${DEFINITION IN SECOND RESOURCE}    ${PRIORITIES 5}
=======================================
--- /atest/testdata/variables/resvarfiles/resource_2.txt Fri Aug 31 03:52:56 2012 +++ /atest/testdata/variables/resvarfiles/resource_2.txt Fri May 10 04:22:40 2013
@@ -1,10 +1,6 @@
-*** Setting ***
-
 *** Variable ***
 ${PRIORITIES_1}    Second Resource File
 ${PRIORITIES_2}    Second Resource File
 ${PRIORITIES_3}    Second Resource File
 ${PRIORITIES_4}    Second Resource File
 ${PRIORITIES_5}    Second Resource File
-
-*** Keyword ***
=======================================
--- /atest/testdata/variables/variables_from_resource_files.txt Wed Mar 20 06:34:45 2013 +++ /atest/testdata/variables/variables_from_resource_files.txt Fri May 10 04:22:40 2013
@@ -2,7 +2,12 @@
 Resource          resvarfiles/resource.txt

 *** Variable ***
-${DEFINITION IN RESOURCE FILE}    ${STRING}
+${DEFINITION IN RESOURCE (1)}    ${STRING}
+${DEFINITION IN RESOURCE (2)}    ${LIST[0]}! ${ONE ITEM[0]}
+${DEFINITION IN RESOURCE (3)}    ${LIST WITH ESCAPES}
+@{DEFINITION IN RESOURCE (4)}    @{LIST WITH ESCAPES}
+${ORIGINAL DEFINITION IN SECOND RESOURCE} ${DEFINITION IN SECOND RESOURCE}
+${DEFINITION IN SECOND RESOURCE (local)}    ${PRIORITIES 5}

 *** Test Case ***
 Scalar String
@@ -17,9 +22,6 @@

 Scalar String With Escapes
     Should Be Equal    ${ESCAPES}    one \\ two \\\\ \${non_existing}
-
-Resolving Local Variable Defined From Resource File
-    Should Be Equal    ${DEFINITION IN RESOURCE FILE}    Hello world!

 Empty Scalar String
     Should Be Equal    ${NO VALUE}    ${EMPTY}
@@ -36,10 +38,9 @@
     Should Be True    ${LIST WITH NON STRINGS} == [42, -1.2, True, None]

 Scalar List With Escapes
-    Should Be Equal    ${LIST WITH ESCAPES [0]}    one \\
-    Should Be Equal    ${LIST WITH ESCAPES [1]}    two \\\\
-    Should Be Equal    ${LIST WITH ESCAPES [2]}    three \\\\\\
-    Should Be Equal    ${LIST WITH ESCAPES [3]}    \${non_existing}
+    Test List With Escapes
+    ...    ${LIST WITH ESCAPES [0]}    ${LIST WITH ESCAPES [1]}
+    ...    ${LIST WITH ESCAPES [2]}    ${LIST WITH ESCAPES [3]}
${exp} = Create List one \\ two \\\\ three \\\\\\ \${non_existing}
     Should Be Equal    ${LIST WITH ESCAPES}    ${exp}
Should Be True ${LIST WITH ESCAPES} == ['one \\\\', 'two \\\\\\\\', 'three \\\\\\\\\\\\', '\${non_existing}'] Backslashes are doubled here because 'Should Be True' uses 'eval' internally
@@ -55,10 +56,7 @@
     Should Be True    @{LIST} == ['Hello', 'again', '?']

 List With Escapes
-    Should Be Equal    @{LIST WITH ESCAPES}[0]    one \\
-    Should Be Equal    @{LIST WITH ESCAPES}[1]    two \\\\
-    Should Be Equal    @{LIST WITH ESCAPES}[2]    three \\\\\\
-    Should Be Equal    @{LIST WITH ESCAPES}[3]    \${non_existing}
+    Test List With Escapes    @{LIST WITH ESCAPES}

 List Created From List With Escapes
     Should Be Equal    @{LIST CREATED FROM LIST WITH ESCAPES}[0]    one \\
@@ -103,7 +101,7 @@
Should Be Equal @{ _u_N_de__r _S C ores__ }[0] Variable name with under scores

 Assign Mark With Scalar variable
- Should Be Equal ${ASSING MARK} This syntax works starting from 1.8 + Should Be Equal ${ASSIGN MARK} This syntax works starting from 1.8

 Assign Mark With List variable
     Should Be Equal    @{ASSIGN MARK}[0]    This syntax works
@@ -111,4 +109,21 @@
     Should Be Equal    @{ASSIGN MARK}[2]    from
     Should Be Equal    @{ASSIGN MARK}[3]    ${1.8}

-*** Keyword ***
+Variables From Resource Files Can Be Used In Local Variable Table
+    Should Be Equal    ${DEFINITION IN RESOURCE (1)}    Hello world!
+    Should Be Equal    ${DEFINITION IN RESOURCE (2)}    Hello! Hello again?
+    Test List With Escapes    @{DEFINITION IN RESOURCE (3)}
+    Test List With Escapes    @{DEFINITION IN RESOURCE (4)}
+
+Imported Resource Can Use Variables From Resources It Imports In Its Variable Table + Should Be Equal ${DEFINITION IN SECOND RESOURCE} Second Resource File + Should Be Equal ${ORIGINAL DEFINITION IN SECOND RESOURCE} Second Resource File + Should Be Equal ${DEFINITION IN SECOND RESOURCE (local)} Second Resource File
+
+*** Keywords ***
+Test List With Escapes
+    [Arguments]    ${item1}    ${item2}    ${item3}    ${item4}
+    Should Be Equal    ${item1}    one \\
+    Should Be Equal    ${item2}    two \\\\
+    Should Be Equal    ${item3}    three \\\\\\
+    Should Be Equal    ${item4}    \${non_existing}
=======================================
--- /atest/testdata/variables/variables_from_variable_files.txt Fri Aug 31 03:56:36 2012 +++ /atest/testdata/variables/variables_from_variable_files.txt Fri May 10 04:22:40 2013
@@ -2,6 +2,10 @@
 Variables         resvarfiles/variables.py

 *** Variable ***
+${DEFINITION IN VARIABLE FILE 1}    ${STRING}
+${DEFINITION IN VARIABLE FILE 2}    ${LIST[0]}! ${ONE ITEM[0]}
+${DEFINITION IN VARIABLE FILE 3}    ${LIST WITH ESCAPES}
+@{DEFINITION IN VARIABLE FILE 4}    @{LIST WITH ESCAPES}

 *** Test Case ***
 Scalar String
@@ -32,10 +36,9 @@
     Should Be True    ${LIST WITH NON STRINGS} == [42, -1.2, True, None]

 Scalar List With Escapes
-    Should Be Equal    ${LIST WITH ESCAPES [0]}    one \\
-    Should Be Equal    ${LIST WITH ESCAPES [1]}    two \\\\
-    Should Be Equal    ${LIST WITH ESCAPES [2]}    three \\\\\\
-    Should Be Equal    ${LIST WITH ESCAPES [3]}    \${non_existing}
+    Test List With Escapes
+    ...    ${LIST WITH ESCAPES [0]}    ${LIST WITH ESCAPES [1]}
+    ...    ${LIST WITH ESCAPES [2]}    ${LIST WITH ESCAPES [3]}
${exp} = Create List one \\ two \\\\ three \\\\\\ \${non_existing}
     Should Be Equal    ${LIST WITH ESCAPES}    ${exp}
Should Be True ${LIST WITH ESCAPES} == ['one \\\\', 'two \\\\\\\\', 'three \\\\\\\\\\\\', '\${non_existing}'] Backslashes are doubled here because 'Should Be True' uses 'eval' internally
@@ -57,10 +60,7 @@
     Should Be True    @{LIST} == ['Hello', 'again', '?']

 List With Escapes
-    Should Be Equal    @{LIST WITH ESCAPES}[0]    one \\
-    Should Be Equal    @{LIST WITH ESCAPES}[1]    two \\\\
-    Should Be Equal    @{LIST WITH ESCAPES}[2]    three \\\\\\
-    Should Be Equal    @{LIST WITH ESCAPES}[3]    \${non_existing}
+    Test List With Escapes    @{LIST WITH ESCAPES}

 List With No Items
     [Documentation]    FAIL Non-existing variable '\@{EMPTY LIST}[0]'
@@ -97,4 +97,16 @@
     Should Be Equal    @{underscores}[0]    Variable name with under scores
Should Be Equal @{ _u_N_de__r _S C ores__ }[0] Variable name with under scores

-*** Keyword ***
+Variables From Variable Files Can Be Used In Local Variable Table
+    Should Be Equal    ${DEFINITION IN VARIABLE FILE 1}    Hello world!
+ Should Be Equal ${DEFINITION IN VARIABLE FILE 2} Hello! Hello again?
+    Test List With Escapes    @{DEFINITION IN VARIABLE FILE 3}
+    Test List With Escapes    @{DEFINITION IN VARIABLE FILE 4}
+
+*** Keywords ***
+Test List With Escapes
+    [Arguments]    ${item1}    ${item2}    ${item3}    ${item4}
+    Should Be Equal    ${item1}    one \\
+    Should Be Equal    ${item2}    two \\\\
+    Should Be Equal    ${item3}    three \\\\\\
+    Should Be Equal    ${item4}    \${non_existing}

==============================================================================
Revision: 6bf5f7e3415a
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Fri May 10 04:32:46 2013
Log:      Refactored delayed resolving of variables in variable table.

Update issue 561
Changed delayed vars to use special class instead of a attribute. This is both
cleaner and also safer -- old implementation would have failed if a normal
variable had the special attribute.

Also renamed force_value_resolve -> resolve_delayed.
http://code.google.com/p/robotframework/source/detail?r=6bf5f7e3415a

Modified:
 /src/robot/running/model.py
 /src/robot/variables/variables.py

=======================================
--- /src/robot/running/model.py Thu Mar 28 05:49:06 2013
+++ /src/robot/running/model.py Fri May 10 04:32:46 2013
@@ -145,7 +145,7 @@
context = EXECUTION_CONTEXTS.start_suite(ns, output, self._dry_run_mode)
         if not errors.exit:
             ns.handle_imports()
-        self.variables.force_value_resolve()
+        self.variables.resolve_delayed()
         self._set_variable_dependent_metadata(context, errors)
         output.start_suite(self)
         return context
=======================================
--- /src/robot/variables/variables.py   Thu May  9 01:58:44 2013
+++ /src/robot/variables/variables.py   Fri May 10 04:32:46 2013
@@ -86,19 +86,15 @@

     def _find_variable(self, name):
         variable = utils.NormalizedDict.__getitem__(self, name)
- # FIXME: Delayed are not solved if got through _get_list_var_as_scalar
-        # or _get_scalar_as_list
         return self._solve_delayed(name, variable)

     def _solve_delayed(self, name, value):
-        if value is not None:
-            if hasattr(value, 'delayed_var_value'):
-                v = value()
-                self[name] = v
-                return v
+        if isinstance(value, DelayedVariable):
+            value = value.resolve(name, self)
+            self[name] = value
         return value

-    def force_value_resolve(self):
+    def resolve_delayed(self):
         self.values()

     def _validate_var_name(self, name):
@@ -350,15 +346,7 @@
         self._validate_var_name(name)
         self._validate_var_is_not_scalar_list(name, value)
value = [self._unescape_leading_trailing_spaces(cell) for cell in value]
-        return name, self._delayed_var_value(name, value)
-
-    def _delayed_var_value(self, name, value):
-        def _delayed():
-            if is_list_var(name):
-                return self.replace_list(value)
-            return self.replace_scalar(value[0])
-        _delayed.delayed_var_value = True
-        return _delayed
+        return name, DelayedVariable(value)

     def _unescape_leading_trailing_spaces(self, item):
         if item.endswith(' \\'):
@@ -421,3 +409,14 @@
         if extended:
             return self.has_key(variable)
         return utils.NormalizedDict.has_key(self, variable)
+
+
+class DelayedVariable(object):
+
+    def __init__(self, value):
+        self._value = value
+
+    def resolve(self, name, variables):
+        if is_list_var(name):
+            return variables.replace_list(self._value)
+        return variables.replace_scalar(self._value[0])

==============================================================================
Revision: b8a889e56dbc
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Fri May 10 04:34:26 2013
Log: UG: Fixed example related to using Java classes as variable files and cleaned up variable doc a little.
http://code.google.com/p/robotframework/source/detail?r=b8a889e56dbc

Modified:
 /doc/userguide/src/CreatingTestData/ResourceAndVariableFiles.rst
 /doc/userguide/src/CreatingTestData/Variables.rst

=======================================
--- /doc/userguide/src/CreatingTestData/ResourceAndVariableFiles.rst Mon Oct 15 03:52:11 2012 +++ /doc/userguide/src/CreatingTestData/ResourceAndVariableFiles.rst Fri May 10 04:34:26 2013
@@ -495,7 +495,7 @@
         private String notVariable = "is private";
         public String anotherVariable;

-        public StaticJavaExample(String arg1, String arg2) {
+        public StaticJavaExample() {
             anotherVariable = "another value";
         }
     }
=======================================
--- /doc/userguide/src/CreatingTestData/Variables.rst Thu May 9 06:52:48 2013 +++ /doc/userguide/src/CreatingTestData/Variables.rst Fri May 10 04:34:26 2013
@@ -367,10 +367,9 @@
 The most common source for variables are Variable tables in `test case
 files`_ and `resource files`_. Variable tables are convenient, because they
 allow creating variables in the same place as the rest of the test
-data, and the needed syntax is very simple. Their main disadvantage is
-that they only enable assigning variables into strings or a list of
-strings. If other value types are needed, `variable files`_ are
-probably a better option.
+data, and the needed syntax is very simple. Their main disadvantages are
+that values are always strings and they cannot be created dynamically.
+If either of these is a problem, `variable files`_ can be used instead.

 Creating scalar variables
 `````````````````````````

==============================================================================
Revision: 5676a5318d0e
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Fri May 10 04:34:38 2013
Log:      regen
http://code.google.com/p/robotframework/source/detail?r=5676a5318d0e

Modified:
 /doc/userguide/RobotFrameworkUserGuide.html

=======================================
--- /doc/userguide/RobotFrameworkUserGuide.html Thu May  9 06:53:06 2013
+++ /doc/userguide/RobotFrameworkUserGuide.html Fri May 10 04:34:38 2013
@@ -5575,10 +5575,9 @@
<p>The most common source for variables are Variable tables in <a class="reference internal" href="#test-case-files">test case files</a> and <a class="reference internal" href="#resource-files">resource files</a>. Variable tables are convenient, because they
 allow creating variables in the same place as the rest of the test
-data, and the needed syntax is very simple. Their main disadvantage is
-that they only enable assigning variables into strings or a list of
-strings. If other value types are needed, <a class="reference internal" href="#variable-files">variable files</a> are
-probably a better option.</p>
+data, and the needed syntax is very simple. Their main disadvantages are
+that values are always strings and they cannot be created dynamically.
+If either of these is a problem, <a class="reference internal" href="#variable-files">variable files</a> can be used instead.</p>
 <div class="section" id="creating-scalar-variables">
 <h5>Creating scalar variables</h5>
 <p>The simplest possible variable assignment is setting a string into a
@@ -8510,7 +8509,7 @@
<span class="kd">private</span> <span class="n">String</span> <span class="n">notVariable</span> <span class="o">=</span> <span class="s">&quot;is private&quot;</span><span class="o">;</span> <span class="kd">public</span> <span class="n">String</span> <span class="n">anotherVariable</span><span class="o">;</span>

- <span class="kd">public</span> <span class="nf">StaticJavaExample</span><span class="o">(</span><span class="n">String</span> <span class="n">arg1</span><span class="o">,</span> <span class="n">String</span> <span class="n">arg2</span><span class="o">)</span> <span class="o">{</span> + <span class="kd">public</span> <span class="nf">StaticJavaExample</span><span class="o">()</span> <span class="o">{</span> <span class="n">anotherVariable</span> <span class="o">=</span> <span class="s">&quot;another value&quot;</span><span class="o">;</span>
     <span class="o">}</span>
 <span class="o">}</span>
@@ -16671,7 +16670,7 @@
 <div class="footer">
 <hr class="footer" />
<p>Generated by <a class="reference external" href="http://docutils.sourceforge.net/rst.html";>reStructuredText</a>. Syntax highlighting by <a class="reference external" href="http://pygments.org/";>Pygments</a>.</p>
-<p>Generated on: 2013-05-09 13:53 UTC.
+<p>Generated on: 2013-05-10 11:22 UTC.
 </p>

 </div>

==============================================================================
Revision: 8b2d981e429f
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Fri May 10 04:34:48 2013
Log:      Automated merge with https://robotframework.googlecode.com/hg/
http://code.google.com/p/robotframework/source/detail?r=8b2d981e429f


--

--- You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to