Revision: 3151
Author: jussi.ao.malinen
Date: Tue May  4 06:41:36 2010
Log: Issue 544 (run keywords always on teardown except when fatal exception occurs)
http://code.google.com/p/robotframework/source/detail?r=3151

Deleted:
 /trunk/atest/robot/running/fatal_error_in_suite_teardown.txt
Modified:
 /trunk/atest/robot/running/errors_in_test_teardown.txt
 /trunk/atest/testdata/running/errors_in_test_teardown.txt
 /trunk/src/robot/running/keywords.py

=======================================
--- /trunk/atest/robot/running/fatal_error_in_suite_teardown.txt Tue May 4 05:36:54 2010
+++ /dev/null
@@ -1,10 +0,0 @@
-*** Settings ***
-Suite Setup Run Tests ${EMPTY} running/fatal_error_in_suite_teardown.txt
-Force Tags      not ready  pybot  jybot
-Resource        atest_resource.txt
-
-*** Test Cases ***
-Suite Teardown Should Stop At Fatal Error
-    ${ts} =  Get Test Suite  fatal error in suite teardown
-    Should Be True  len(${ts.teardown.kws}) == 1
-
=======================================
--- /trunk/atest/robot/running/errors_in_test_teardown.txt Tue May 4 05:36:54 2010 +++ /trunk/atest/robot/running/errors_in_test_teardown.txt Tue May 4 06:41:36 2010
@@ -1,6 +1,6 @@
 *** Settings ***
 Suite Setup     Run Tests  ${EMPTY}  running/errors_in_test_teardown.txt
-Force Tags      not ready  pybot  jybot
+Force Tags      regression  pybot  jybot
 Resource        atest_resource.txt

 *** Test Cases ***
@@ -15,3 +15,20 @@
 Test With A Fatal Error In Teardown
     ${tc} =  Check Test Case  ${TESTNAME}
     Should Be True  len(${tc.teardown.kws}) == 1
+
+Suite Teardown Is Executed Fully
+    ${ts} =  Get Test Suite  errors in test teardown
+    Check Log Message  ${ts.teardown.kws[0].msgs[0]}  Suite Message 1  FAIL
+ Check Log Message ${ts.teardown.kws[1].msgs[0]} Suite Message 2 (with ∏ön ÄßÇïï €§) FAIL + Check Log Message ${ts.teardown.kws[2].msgs[0]} This As Well Should Be Executed
+    ${msg} =  Catenate  SEPARATOR=\n
+    ...  Suite teardown failed:
+    ...  Several failures occurred:\n
+    ...  1) Suite Message 1\n
+    ...  2) Suite Message 2 (with ∏ön ÄßÇïï €§)
+    Should Be Equal  ${ts.message}  ${msg}
+
+Suite Teardown Should Stop At Fatal Error
+    Run Tests  ${EMPTY}  running/fatal_error_in_suite_teardown.txt
+    ${ts} =  Get Test Suite  fatal error in suite teardown
+    Should Be True  len(${ts.teardown.kws}) == 1
=======================================
--- /trunk/atest/testdata/running/errors_in_test_teardown.txt Tue May 4 05:36:54 2010 +++ /trunk/atest/testdata/running/errors_in_test_teardown.txt Tue May 4 06:41:36 2010
@@ -4,17 +4,25 @@

 *** Test Cases ***
 Test With One Error In Teardown
- [documentation] FAIL Teardown failed:\nMessage\n\nAlso teardown of the parent suite failed.
+    [documentation]  FAIL Teardown failed:\n
+    ...  Message\n\n
+    ...  Also teardown of the parent suite failed.
     No Operation
     [teardown]  One Error

 Test With Many Errors In Teardown
- [documentation] FAIL Teardown failed:\nMessage 1\n\nAlso teardown of the parent suite failed.
+    [documentation]  FAIL Teardown failed:\n
+    ...  Several failures occurred:\n\n
+    ...  1) Message 1\n\n
+    ...  2) Message 2\n\n
+    ...  Also teardown of the parent suite failed.
     No Operation
     [teardown]  Many Errors

 Test With A Fatal Error In Teardown
- [documentation] FAIL Teardown failed:\nFatalCatastrophyException\n\nAlso teardown of the parent suite failed.
+    [documentation]  FAIL Teardown failed:\n
+    ...  FatalCatastrophyException\n\n
+    ...  Also teardown of the parent suite failed.
     No Operation
     [teardown]  Fatal Error

@@ -34,5 +42,5 @@

 Suite Teardown With Errors
     Fail  Suite Message 1
-    Fail  Suite Message 2
+    Fail  Suite Message 2 (with ∏ön ÄßÇïï €§)
     Log  This As Well Should Be Executed
=======================================
--- /trunk/src/robot/running/keywords.py        Tue May  4 05:32:33 2010
+++ /trunk/src/robot/running/keywords.py        Tue May  4 06:41:36 2010
@@ -30,11 +30,23 @@
                 kw.run(output, namespace)
             except ExecutionFailed, err:
                 errors.extend(err.get_errors())
-                if not err.cont:
+                if not self._continue_on_failure(err):
                     break
         if errors:
             raise ExecutionFailures(errors)

+    def _continue_on_failure(self, err):
+        if err.cont:
+            return True
+        if err.exit:
+            return False
+        return self._in_test_or_suite_teardown()
+
+    def _in_test_or_suite_teardown(self):
+        from robot.running import NAMESPACES
+        test_or_suite = NAMESPACES.current.test or NAMESPACES.current.suite
+        return test_or_suite.status != 'RUNNING'
+
     def __nonzero__(self):
         return bool(self._keywords)

Reply via email to