Revision: 3525
Author: KariHusa
Date: Wed May 26 02:04:27 2010
Log: handle continuing rows at the start of the table
http://code.google.com/p/robotframework/source/detail?r=3525
Modified:
/trunk/src/robot/parsing/populator.py
/trunk/src/robot/running/model.py
/trunk/utest/parsing/test_populator.py
=======================================
--- /trunk/src/robot/parsing/populator.py Mon May 24 07:35:24 2010
+++ /trunk/src/robot/parsing/populator.py Wed May 26 02:04:27 2010
@@ -59,7 +59,7 @@
self._populator.populate()
def _is_continuing(self, row):
- return row.is_continuing()
+ return row.is_continuing() and self._populator
def _is_cacheable_comment_row(self, row):
return row.is_commented()
@@ -88,7 +88,7 @@
class _StepContainingTablePopulator(_TablePopulator):
def _is_continuing(self, row):
- return row.is_indented() or row.is_commented()
+ return row.is_indented() and self._populator or row.is_commented()
def _is_cacheable_comment_row(self, row):
return row.is_commented() and isinstance(self._populator,
NullPopulator)
@@ -192,7 +192,7 @@
return StepPopulator(self._test_or_uk.add_step)
def _continues(self, row):
- return row.is_continuing() or \
+ return row.is_continuing() and self._populator or \
(isinstance(self._populator, ForLoopPopulator) and
row.is_indented())
def _setting_setter(self, row):
@@ -237,7 +237,7 @@
class VariablePopulator(_PropertyPopulator):
def _add(self, row):
- if row.is_continuing():
+ if row.is_continuing() and self._value:
row = row.dedent()
self._value.extend(row.all)
@@ -270,3 +270,4 @@
class NullPopulator(Populator):
def add(self, row): pass
def populate(self): pass
+ def __nonzero__(self): return False
=======================================
--- /trunk/src/robot/running/model.py Tue May 25 06:08:31 2010
+++ /trunk/src/robot/running/model.py Wed May 26 02:04:27 2010
@@ -237,6 +237,8 @@
self.timeout.replace_variables(context.get_current_vars())
if errors:
return 'Test case initialization
failed:\n%s' % '\n'.join(errors)
+ if not self.name:
+ return 'Test case name is required.'
if not self.keywords:
return 'Test case contains no keywords'
return None
=======================================
--- /trunk/utest/parsing/test_populator.py Tue May 25 04:32:27 2010
+++ /trunk/utest/parsing/test_populator.py Wed May 26 02:04:27 2010
@@ -148,6 +148,28 @@
tag = self._setting_with(tag_name)
assert_equals(tag.value, exp_value)
+ def test_continuing_in_the_begining_of_the_setting_table(self):
+ self._create_table('Settings', [['...']])
+ assert_equals(self._logger.value(), "Invalid syntax in file 'None'
in "
+ "table 'Settings':
Non-existing "
+ "setting '...'.")
+
+ def test_continuing_in_the_begining_of_the_variable_table(self):
+ self._create_table('Variables', [['...', 'val']])
+ self._assert_variable(0, '...', ['val'])
+
+ def test_continuing_in_the_begining_of_the_testcase_table(self):
+ self._create_table('test cases', [['...', 'foo']])
+ assert_equals(self._first_test().name, '...')
+
+ def test_continuing_in_the_begining_of_the_testcase_table2(self):
+ self._create_table('test cases', [['', '...', 'foo']])
+ assert_equals(self._first_test().name, '')
+
+ def test_continuing_in_the_begining_of_the_keyword_table(self):
+ self._create_table('keywords', [['...', 'foo']])
+ assert_equals(self._nth_uk(1).name, '...')
+
def test_invalid_settings(self):
self._create_table('Settings', [['In valid', 'val ue']])
assert_equals(self._logger.value(), "Invalid syntax in file 'None'
in "
@@ -203,11 +225,12 @@
self._create_table('Test cases', [['My test name', 'Log
Many', 'foo'],
['', '...', 'bar', 'quux'],
['Another test'],
+ ['', '...'],
['', 'Log Many', 'quux'],
['', '...', 'fooness'],
['', 'Log', 'barness']])
assert_equals(len(self._first_test().steps), 1)
- assert_equals(len(self._nth_test(2).steps), 2)
+ assert_equals(len(self._nth_test(2).steps), 3)
def test_for_loop(self):
self._create_table('Test cases', [['For loop test'],
@@ -344,10 +367,10 @@
self._assert_import(0, 'FooBarness', [])
assert_equals(len(self._datafile.variable_table.variables), 1)
assert_equals(len(self._datafile.testcase_table.tests), 1)
- assert_equals(len(self._nth_uk(0).steps), 1)
+ assert_equals(len(self._nth_uk(1).steps), 1)
def _nth_uk(self, index):
- return self._datafile.keyword_table.keywords[index]
+ return self._datafile.keyword_table.keywords[index-1]
class TestPopulatingComments(_PopulatorTest):