diff options
author | Jose Lausuch <jose.lausuch@ericsson.com> | 2017-05-05 14:33:49 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-05-05 14:33:49 +0000 |
commit | 25e6056936b358d7556865deb8f3e86f63248efe (patch) | |
tree | 383caa032bc865e660c2181d10da3e29c852cb3e /functest/core | |
parent | 6e4d097a8881fa0cfcc2c192639eb0f17ce025a2 (diff) | |
parent | ee26a1ca85fc5fac6df6c39f362fad83de73c0cc (diff) |
Merge "Print the real testcase duration"
Diffstat (limited to 'functest/core')
-rw-r--r-- | functest/core/testcase.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/functest/core/testcase.py b/functest/core/testcase.py index 217f07e5..fd892849 100644 --- a/functest/core/testcase.py +++ b/functest/core/testcase.py @@ -43,6 +43,24 @@ class TestCase(object): self.start_time = "" self.stop_time = "" + def get_duration(self): + """Return the duration of the test case. + + Returns: + duration if start_time and stop_time are set + "XX:XX" otherwise. + """ + try: + assert self.start_time + assert self.stop_time + if self.stop_time < self.start_time: + return "XX:XX" + return "{0[0]:02.0f}:{0[1]:02.0f}".format(divmod( + self.stop_time - self.start_time, 60)) + except Exception: + self.__logger.error("Please run test before getting the duration") + return "XX:XX" + def check_result(self): """Interpret the result of the test case. |