Revision: 2806
Author: jprantan
Date: Tue Mar 30 04:42:34 2010
Log: Implemented Run Keyword If Timeout Occurred, issue 342.
http://code.google.com/p/robotframework/source/detail?r=2806
Modified:
/trunk/src/robot/libraries/BuiltIn.py
/trunk/src/robot/running/model.py
/trunk/src/robot/running/timeouts.py
=======================================
--- /trunk/src/robot/libraries/BuiltIn.py Tue Mar 30 02:20:39 2010
+++ /trunk/src/robot/libraries/BuiltIn.py Tue Mar 30 04:42:34 2010
@@ -967,6 +967,21 @@
if test.status == 'PASS':
return self.run_keyword(name, *args)
+ def run_keyword_if_timeout_occurred(self, name, *args):
+ """Runs the given keyword if either a test or a keyword timeout
has occurred.
+
+ This keyword can only be used in a test teardown. Trying to use it
+ anywhere else results in an error.
+
+ Otherwise, this keyword works exactly like `Run Keyword`, see its
+ documentation for more details.
+
+ Available in Robot Framework 2.5 and newer.
+ """
+ test = self._get_test_in_teardown('Run Keyword If Timeout
Occurred')
+ if test.timeout.any_timeout_occurred():
+ return self.run_keyword(name, *args)
+
def _get_test_in_teardown(self, kwname):
test = NAMESPACES.current.test
if test is not None and test.status != 'RUNNING':
=======================================
--- /trunk/src/robot/running/model.py Wed Mar 24 03:07:38 2010
+++ /trunk/src/robot/running/model.py Tue Mar 30 04:42:34 2010
@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
from robot import utils
from robot.common import BaseTestSuite, BaseTestCase
from robot.parsing import TestSuiteData
@@ -214,7 +213,8 @@
if fixture:
try:
fixture.run(output, namespace)
- except ExecutionFailed:
+ except ExecutionFailed, err:
+ self.timeout.set_keyword_timeout(err.timeouted)
return utils.get_error_message()
def _run_keywords(self, output, namespace, setup_err):
@@ -222,7 +222,8 @@
for kw in self.keywords:
try:
kw.run(output, namespace)
- except ExecutionFailed:
+ except ExecutionFailed, err:
+ self.timeout.set_keyword_timeout(err.timeouted)
return utils.get_error_message()
def _get_message(self, setup_err, kw_err):
=======================================
--- /trunk/src/robot/running/timeouts.py Thu Mar 4 00:02:02 2010
+++ /trunk/src/robot/running/timeouts.py Tue Mar 30 04:42:34 2010
@@ -103,6 +103,14 @@
class TestTimeout(_Timeout):
type = 'test'
+ _kw_timeout_occurred = False
+
+ def set_keyword_timeout(self, timeout_occurred):
+ if not self._kw_timeout_occurred:
+ self._kw_timeout_occurred = timeout_occurred
+
+ def any_timeout_occurred(self):
+ return self.timed_out() or self._kw_timeout_occurred
class KeywordTimeout(_Timeout):
To unsubscribe from this group, send email to
robotframework-commit+unsubscribegooglegroups.com or reply to this email with the words
"REMOVE ME" as the subject.