Revision: 3708
Author: janne.t.harkonen
Date: Fri Jun 4 03:25:42 2010
Log: added methods for getting list representation of steps, needed in RIDE
http://code.google.com/p/robotframework/source/detail?r=3708
Modified:
/trunk/src/robot/parsing/model.py
/trunk/utest/parsing/test_model.py
=======================================
--- /trunk/src/robot/parsing/model.py Thu Jun 3 02:51:52 2010
+++ /trunk/src/robot/parsing/model.py Fri Jun 4 03:25:42 2010
@@ -482,6 +482,9 @@
def apply_template(self, template):
return Step(['Fail', 'Templates not supported with FOR loops.'])
+ def as_list(self):
+ return [': FOR'] + self.vars + ['IN RANGE' if self.range
else 'IN'] + self.items
+
class Step(object):
@@ -511,5 +514,8 @@
def apply_template(self, template):
if self.is_comment():
return self
+ return Step([template] + self.as_list())
+
+ def as_list(self):
kw = [self.keyword] if self.keyword is not None else []
- return Step([template] + self.assign + kw + self.args)
+ return self.assign + kw + self.args
=======================================
--- /trunk/utest/parsing/test_model.py Thu Jun 3 02:51:52 2010
+++ /trunk/utest/parsing/test_model.py Fri Jun 4 03:25:42 2010
@@ -264,6 +264,10 @@
assert_true(Step([], comment="comment").is_comment())
assert_false(Step(['KW'], comment="comment").is_comment())
+ def test_representation(self):
+ assert_equals(Step(['${v}, @{list}=', 'KW', 'arg']).as_list(),
+ ['${v}, @{list}=', 'KW', 'arg'])
+
def test_apply_template_to_step(self):
kw = 'Should Be Equal'
args = ['Foo', 'Bar']
@@ -306,6 +310,12 @@
self._test(['what', 'ever', 'in range', 'IN', 'whatever'],
['what', 'ever'], ['IN', 'whatever'], range=True)
+ def test_representation(self):
+
assert_equals(ForLoop(['${var}', 'IN', 'value1', 'value2']).as_list(),
+ [': FOR', '${var}', 'IN', 'value1', 'value2'])
+ assert_equals(ForLoop(['${v2}', '${v2}', 'IN
RANGE', '100']).as_list(),
+ [': FOR', '${v2}', '${v2}', 'IN RANGE', '100'])
+
def _test(self, content, vars, items, range=False):
loop = ForLoop(content)
assert_equal(loop.vars, vars)