Revision: 3607
Author: KariHusa
Date: Thu May 27 23:28:51 2010
Log: Started implementing test template, issue 500
http://code.google.com/p/robotframework/source/detail?r=3607
Modified:
/trunk/src/robot/parsing/model.py
/trunk/src/robot/parsing/settings.py
/trunk/utest/parsing/test_populator.py
=======================================
--- /trunk/src/robot/parsing/model.py Thu May 27 02:54:57 2010
+++ /trunk/src/robot/parsing/model.py Thu May 27 23:28:51 2010
@@ -20,7 +20,7 @@
from robot import utils
from settings import (Documentation, Fixture, Timeout, Tags, Metadata,
- Library, Resource, Variables, Arguments, Return)
+ Library, Resource, Variables, Arguments, Return,
Template)
from datareader import FromFilePopulator, FromDirectoryPopulator
@@ -216,6 +216,7 @@
self.test_setup = Fixture(self)
self.test_teardown = Fixture(self)
self.test_timeout = Timeout(self)
+ self.test_template = Template(self)
self.force_tags = Tags(self)
self.default_tags = Tags(self)
self.metadata = []
@@ -268,6 +269,7 @@
'Test Precondition':
self.test_setup.set,
'Test Teardown':
self.test_teardown.set,
'Test Postcondition':
self.test_teardown.set,
+ 'Test Template':
self.test_template.set,
'Force Tags': self.force_tags.set,
'Default Tags': self.default_tags.set,
'Test Timeout': self.test_timeout.set,
@@ -386,6 +388,7 @@
self.parent = parent
self.name = name
self.doc = Documentation(self)
+ self.template = Template(self)
self.tags = Tags(self)
self.setup = Fixture(self)
self.teardown = Fixture(self)
@@ -396,6 +399,7 @@
def _get_setters(self):
return utils.NormalizedDict({'Documentation': self.doc.set,
'Document': self.doc.set,
+ 'Template': self.template.set,
'Setup': self.setup.set,
'Precondition': self.setup.set,
'Teardown': self.teardown.set,
=======================================
--- /trunk/src/robot/parsing/settings.py Wed May 26 05:34:38 2010
+++ /trunk/src/robot/parsing/settings.py Thu May 27 23:28:51 2010
@@ -62,6 +62,18 @@
self.value = self._concat_string_with_value(self.value, value)
+class Template(_Setting):
+
+ def _init(self):
+ self.value = None
+
+ def _set(self, value):
+ self.value = value[0] if value else ''
+
+ def is_set(self):
+ return self.value is not None
+
+
class Fixture(_Setting):
def _init(self):
=======================================
--- /trunk/utest/parsing/test_populator.py Wed May 26 02:24:22 2010
+++ /trunk/utest/parsing/test_populator.py Thu May 27 23:28:51 2010
@@ -114,6 +114,7 @@
def test_adding_settings(self):
doc = 'This is doc'
+ template = 'Foo'
more_doc = 'smore'
force_tags = 'force'
more_tags = 'more tagness'
@@ -133,7 +134,8 @@
['De Fault TAGS', more_tags],
['...', even_more_tags],
['test timeout', 'timeout
message'],
- ['test timeout', more_doc]
+ ['test timeout', more_doc],
+ ['test template', template]
])
self._assert_setting('doc', doc + ' ' + more_doc)
self._assert_fixture('suite_setup', setup_name, setup_args)
@@ -143,6 +145,7 @@
timeout = self._setting_with('test_timeout')
assert_equals(timeout.value, '1s')
assert_equals(timeout.message, 'timeout message '+more_doc)
+ self._assert_setting('test_template', template)
def _assert_tags(self, tag_name, exp_value):
tag = self._setting_with(tag_name)
@@ -310,6 +313,15 @@
"in test case 'My test name': "
"Non-existing setting 'Aasi'.")
+ def test_test_template_overrides_setting(self):
+ setting_test_template = 'Foo'
+ test_test_template = 'Bar'
+ self._create_table('Settings', [['Test Template',
setting_test_template]],
+ eof=False)
+ self._create_table('Test Cases', [['','[Template]',
test_test_template]])
+ test = self._first_test()
+ assert_equals(test.template.value, test_test_template)
+
def test_invalid_keyword_settings(self):
self._create_table('Keywords', [['My User Keyword'],
['', '[ank ka]']])