2 new revisions:

Revision: 27e5c2f7c82e
Branch:   default
Author:   Pekka Klärck
Date:     Sun May 26 02:31:26 2013
Log:      new run: support for templates
http://code.google.com/p/robotframework/source/detail?r=27e5c2f7c82e

Revision: 450a98eab6af
Branch:   default
Author:   Pekka Klärck
Date:     Sun May 26 03:29:36 2013
Log:      new run: support disabling setup/teardown with NONE
http://code.google.com/p/robotframework/source/detail?r=450a98eab6af

==============================================================================
Revision: 27e5c2f7c82e
Branch:   default
Author:   Pekka Klärck
Date:     Sun May 26 02:31:26 2013
Log:      new run: support for templates
http://code.google.com/p/robotframework/source/detail?r=27e5c2f7c82e

Modified:
 /atest/robot/running/test_template.txt
 /atest/testdata/running/test_template.txt
 /src/robot/new_running/builder.py
 /src/robot/new_running/defaults.py
 /src/robot/new_running/model.py
 /src/robot/new_running/runner.py
 /utest/new_running/test_builder.py

=======================================
--- /atest/robot/running/test_template.txt      Fri May 24 07:29:50 2013
+++ /atest/robot/running/test_template.txt      Sun May 26 02:31:26 2013
@@ -9,11 +9,17 @@

 Test Default Template
     Check Test Case  ${TESTNAME}
+
+Test Continue On Failure
+    Check Test Case  ${TESTNAME}

 Test Overriding Default Template In Test
     Check Test Case  ${TESTNAME}

-Test Overriding Default Template In Test With Empty
+Test Overriding Default Template In Test With Empty Value
+    Check Test Case  ${TESTNAME}
+
+Test Overriding Default Template In Test With NONE Value
     Check Test Case  ${TESTNAME}

 Test Template With Variables
=======================================
--- /atest/testdata/running/test_template.txt   Fri May 24 07:29:50 2013
+++ /atest/testdata/running/test_template.txt   Sun May 26 02:31:26 2013
@@ -11,23 +11,34 @@
   Fail  Fail

 Test Default Template
- [Documentation] FAIL Several failures occurred:\n\n1) Something != Different\n\n2) 42 != 43
+  [Documentation]  FAIL Something != Different
   Same  Same
+  42  42
   Something  Different
+
+Test Continue On Failure
+ [Documentation] FAIL Several failures occurred:\n\n1) 42 != 43\n\n2) Something != Different
+  Same  Same
   42  43
+  Something  Different

 Test Overriding Default Template In Test
   [Documentation]  FAIL Same == Same
   [Template]  Should Not Be Equal
   Same  Same
+  42  43
   Something  Different
-  42  43

-Test Overriding Default Template In Test With Empty
+Test Overriding Default Template In Test With Empty Value
   [documentation]  FAIL This should be executed as normal keyword
   [Template]
   Fail  This should be executed as normal keyword

+Test Overriding Default Template In Test With NONE Value
+  [documentation]  FAIL This should be executed as normal keyword
+  [Template]    NoNe
+  Fail  This should be executed as normal keyword
+
 Test Template With Variables
   [Template]  Expect Exactly Two Args
   ${VARIABLE}  ${VARIABLE}
=======================================
--- /src/robot/new_running/builder.py   Sun May 26 01:12:36 2013
+++ /src/robot/new_running/builder.py   Sun May 26 02:31:26 2013
@@ -66,11 +66,12 @@
         test = suite.tests.create(name=data.name,
                                   doc=unicode(data.doc),
                                   tags=values.tags.value,
+ continue_on_failure=bool(values.template),
                                   timeout=TestTimeout(values.timeout.value,
values.timeout.message))
         self._create_step(test, values.setup, 'setup')
         for step_data in data.steps:
-            self._create_step(test, step_data)
+ self._create_step(test, step_data, template=values.template.value)
         self._create_step(test, values.teardown, 'teardown')

     def _create_user_keyword(self, suite, data):
@@ -92,20 +93,23 @@
             value = data.value
         suite.variables.create(name=data.name, value=value)

-    def _create_step(self, parent, data, type='kw'):
+    def _create_step(self, parent, data, type='kw', template=None):
         if not data or data.is_comment():
             return
         if data.is_for_loop():
-            self._create_for_loop(parent, data)
+            self._create_for_loop(parent, data, template)
+        elif template and template.upper() != 'NONE':
+            parent.keywords.create(name=template,
+ args=tuple(data.as_list(include_comment=False)))
         else:
             parent.keywords.create(name=data.keyword,
                                    args=tuple(data.args),
                                    assign=tuple(data.assign),
                                    type=type)

-    def _create_for_loop(self, parent, data):
+    def _create_for_loop(self, parent, data, template):
         loop = parent.keywords.append(ForLoop(vars=data.vars,
                                               items=data.items,
                                               range=data.range))
         for step in data.steps:
-            self._create_step(loop, step)
+            self._create_step(loop, step, template=template)
=======================================
--- /src/robot/new_running/defaults.py  Mon May 20 05:38:18 2013
+++ /src/robot/new_running/defaults.py  Sun May 26 02:31:26 2013
@@ -38,5 +38,4 @@
         self.teardown = test.teardown or defaults.teardown
         self.timeout = test.timeout or defaults.timeout
         self.template = test.template or defaults.template
-        # TODO: Handle 'NONE' template (and other NONE values)
self.tags = (test.tags or defaults.default_tags) + defaults.force_tags
=======================================
--- /src/robot/new_running/model.py     Fri May 24 12:54:23 2013
+++ /src/robot/new_running/model.py     Sun May 26 02:31:26 2013
@@ -39,6 +39,10 @@
     def keyword(self):
         return self.name

+    # TODO: Remove compatibility
+    def apply_template(self, template):
+        return self
+

 class ForLoop(Keyword):
     keyword_class = Keyword
@@ -62,11 +66,19 @@
     def steps(self):
         return self.keywords

+    # TODO: Remove compatibility
+    def apply_template(self, template):
+        return self
+

 class TestCase(model.TestCase):
-    __slots__ = []
+    __slots__ = ['continue_on_failure']
     keyword_class = Keyword

+    def __init__(self, continue_on_failure=False, **kwargs):
+        model.TestCase.__init__(self, **kwargs)
+        self.continue_on_failure = continue_on_failure
+

 class TestSuite(model.TestSuite):
     __slots__ = []
@@ -74,8 +86,8 @@
     keyword_class = Keyword
     status = 'RUNNING'   # TODO: Remove compatibility

-    def __init__(self, *args, **kwargs):
-        model.TestSuite.__init__(self, *args, **kwargs)
+    def __init__(self, **kwargs):
+        model.TestSuite.__init__(self, **kwargs)
         self.imports = []
         self.user_keywords = []
         self.variables = []
=======================================
--- /src/robot/new_running/runner.py    Fri May 24 09:04:44 2013
+++ /src/robot/new_running/runner.py    Sun May 26 02:31:26 2013
@@ -85,7 +85,7 @@
doc=self._resolve_setting(test.doc),
                                           tags=test.tags,
                                           starttime=utils.get_timestamp())
-        keywords = Keywords(test.keywords.normal)
+        keywords = Keywords(test.keywords.normal, test.continue_on_failure)
result.timeout = test.timeout # TODO: Cleaner implementation to ...
         result.status = 'RUNNING'       # ... activate timeouts
         self._context.start_test(result)
=======================================
--- /utest/new_running/test_builder.py  Fri May 24 06:02:20 2013
+++ /utest/new_running/test_builder.py  Sun May 26 02:31:26 2013
@@ -6,65 +6,68 @@


 CURDIR = dirname(abspath(__file__))
-DATADIR = normpath(join(CURDIR, '..', '..', 'atest', 'testdata', 'misc'))
+DATADIR = join(CURDIR, '..', '..', 'atest', 'testdata', 'misc')
+
+
+def build(*paths):
+    paths = [normpath(join(DATADIR, p)) for p in paths]
+    suite = TestSuiteBuilder().build(*paths)
+    assert_true(isinstance(suite, TestSuite))
+    assert_equals(suite.source, paths[0] if len(paths) == 1 else '')
+    return suite
+
+
+def assert_keyword(kw, assign=(), name='', args=(), type='kw'):
+    assert_equals(kw.name, name)
+    assert_equals(kw.args, args)
+    assert_equals(kw.assign, assign)
+    assert_equals(kw.type, type)


 class TestBuilding(unittest.TestCase):

-    def _build(self, *paths):
-        paths = [join(DATADIR, p) for p in paths]
-        suite = TestSuiteBuilder().build(*paths)
-        assert_true(isinstance(suite, TestSuite))
-        assert_equals(suite.source, paths[0] if len(paths) == 1 else '')
-        return suite
-
     def test_suite_data(self):
-        suite = self._build('pass_and_fail.txt')
+        suite = build('pass_and_fail.txt')
         assert_equals(suite.name, 'Pass And Fail')
         assert_equals(suite.doc, 'Some tests here')
         assert_equals(suite.metadata, {})

     def test_imports(self):
-        imp = self._build('dummy_lib_test.txt').imports[0]
+        imp = build('dummy_lib_test.txt').imports[0]
         assert_equals(imp.type, 'Library')
         assert_equals(imp.name, 'DummyLib')
         assert_equals(imp.args, ())

     def test_variables(self):
-        variables = self._build('pass_and_fail.txt').variables
+        variables = build('pass_and_fail.txt').variables
         assert_equals(variables[0].name, '${LEVEL1}')
         assert_equals(variables[0].value, 'INFO')
         assert_equals(variables[1].name, '${LEVEL2}')
         assert_equals(variables[1].value, 'DEBUG')

     def test_user_keywords(self):
-        uk = self._build('pass_and_fail.txt').user_keywords[0]
+        uk = build('pass_and_fail.txt').user_keywords[0]
         assert_equals(uk.name, 'My Keyword')
         assert_equals(uk.args, ('${who}',))

     def test_test_data(self):
-        test = self._build('pass_and_fail.txt').tests[1]
+        test = build('pass_and_fail.txt').tests[1]
         assert_equals(test.name, 'Fail')
         assert_equals(test.doc, 'FAIL Expected failure')
         assert_equals(list(test.tags), ['fail', 'force'])
         assert_true(not test.timeout)
+        assert_equals(test.continue_on_failure, False)

     def test_test_keywords(self):
-        kw = self._build('pass_and_fail.txt').tests[0].keywords[0]
-        assert_equals(kw.name, 'My Keyword')
-        assert_equals(kw.args, ('Pass',))
-        assert_equals(kw.assign, ())
-        assert_equals(kw.type, kw.KEYWORD_TYPE)
+        kw = build('pass_and_fail.txt').tests[0].keywords[0]
+        assert_keyword(kw, (), 'My Keyword', ('Pass',))

     def test_assign(self):
-        kw = self._build('unicode.txt').tests[1].keywords[0]
-        assert_equals(kw.assign, ('${msg} =',))
-        assert_equals(kw.name, 'Evaluate')
-        assert_equals(kw.args, (r"u'Fran\\xe7ais'",))
-        assert_equals(kw.type, kw.KEYWORD_TYPE)
+        kw = build('unicode.txt').tests[1].keywords[0]
+ assert_keyword(kw, ('${msg} =',), 'Evaluate', (r"u'Fran\\xe7ais'",))

     def test_directory_suite(self):
-        suite = self._build('suites')
+        suite = build('suites')
         assert_equals(suite.name, 'Suites')
         assert_equals(suite.suites[1].name, 'Subsuites')
         assert_equals(suite.suites[-1].name, 'Tsuite3')
@@ -73,26 +76,27 @@
         assert_equals(suite.suites[1].suites[1].tests[0].id, 's1-s2-s2-t1')

     def test_multiple_inputs(self):
-        suite = self._build('pass_and_fail.txt', 'normal.txt')
+        suite = build('pass_and_fail.txt', 'normal.txt')
         assert_equals(suite.name, 'Pass And Fail & Normal')
         assert_equals(suite.suites[0].name, 'Pass And Fail')
         assert_equals(suite.suites[1].name, 'Normal')
         assert_equals(suite.suites[1].tests[1].id, 's1-s2-t2')

     def test_suite_setup_and_teardown(self):
-        suite = self._build('setups_and_teardowns.txt')
-        assert_equals(suite.keywords.setup.name, '${SUITE SETUP}')
-        assert_equals(suite.keywords.teardown.name, '${SUITE TEARDOWN}')
+        kws = build('setups_and_teardowns.txt').keywords
+        assert_keyword(kws.setup, name='${SUITE SETUP}', type='setup')
+ assert_keyword(kws.teardown, name='${SUITE TEARDOWN}', type='teardown')

     def test_test_setup_and_teardown(self):
-        test = self._build('setups_and_teardowns.txt').tests[0]
-        assert_equals(test.keywords.setup.name, 'Test Setup')
-        assert_equals(test.keywords.teardown.name, 'Test Teardown')
-        assert_equals([kw.name for kw in test.keywords],
+        kws = build('setups_and_teardowns.txt').tests[0].keywords
+        assert_keyword(kws.setup, name='Test Setup', type='setup')
+        assert_keyword(kws.teardown, name='Test Teardown', type='teardown')
+        assert_equals([kw.name for kw in kws],
                       ['Test Setup', 'Keyword', 'Test Teardown'])
+        assert_equals([kw.name for kw in kws.normal], ['Keyword'])

     def test_test_timeout(self):
-        tests = self._build('timeouts.txt').tests
+        tests = build('timeouts.txt').tests
         assert_equals(tests[0].timeout.string, '1min 42s')
         assert_equals(tests[0].timeout.message, '')
         assert_equals(tests[1].timeout.string, '1d2h')
@@ -102,6 +106,28 @@

     def test_keyword_timeout(self):
         # TODO: Tests and uks have inconsistent timeout types.
-        kw = self._build('timeouts.txt').user_keywords[0]
+        kw = build('timeouts.txt').user_keywords[0]
         assert_equals(kw.timeout.value, '42')
         assert_equals(kw.timeout.message, 'My message')
+
+
+class TestTemplates(unittest.TestCase):
+
+    def test_from_setting_table(self):
+        test = build('../running/test_template.txt').tests[0]
+ assert_keyword(test.keywords[0], (), 'Should Be Equal',('Fail', 'Fail'))
+        assert_equals(test.continue_on_failure, True)
+
+    def test_from_test_case(self):
+        test = build('../running/test_template.txt').tests[3]
+        kws = test.keywords
+        assert_keyword(kws[0], (), 'Should Not Be Equal', ('Same', 'Same'))
+        assert_keyword(kws[1], (), 'Should Not Be Equal', ('42', '43'))
+ assert_keyword(kws[2], (), 'Should Not Be Equal', ('Something', 'Different'))
+        assert_equals(test.continue_on_failure, True)
+
+    def test_no_variable_assign(self):
+        test = build('../running/test_template.txt').tests[8]
+        assert_keyword(test.keywords[0], (), 'Expect Exactly Three Args',
+ ('${SAME VARIABLE}', 'Variable content', '${VARIABLE}'))
+        assert_equals(test.continue_on_failure, True)

==============================================================================
Revision: 450a98eab6af
Branch:   default
Author:   Pekka Klärck
Date:     Sun May 26 03:29:36 2013
Log:      new run: support disabling setup/teardown with NONE
http://code.google.com/p/robotframework/source/detail?r=450a98eab6af

Modified:
 /src/robot/new_running/runner.py

=======================================
--- /src/robot/new_running/runner.py    Sun May 26 02:31:26 2013
+++ /src/robot/new_running/runner.py    Sun May 26 03:29:36 2013
@@ -125,6 +125,8 @@
             name = self._variables.replace_string(data.name)
         except DataError, err:
             return err
+        if name.upper() == 'NONE':
+            return None
         kw = Keyword(name, data.args, type=type)
         try:
             kw.run(self._context)

--

--- 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