Fix duration calculation 40/70940/2
authorCédric Ollivier <cedric.ollivier@orange.com>
Sat, 5 Sep 2020 10:10:29 +0000 (12:10 +0200)
committerCédric Ollivier <cedric.ollivier@orange.com>
Sat, 5 Sep 2020 10:51:22 +0000 (12:51 +0200)
It falsy printed 00:60

Change-Id: Ib2852268a6833b353232c80e9013b6926058479c
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
(cherry picked from commit 242696fe51c7dc3530587350550ab07164706e56)

xtesting/core/testcase.py

index c4dec22..8faf3f4 100644 (file)
@@ -107,8 +107,9 @@ class TestCase():
             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))
+            return "{}:{}".format(
+                str(int(self.stop_time - self.start_time) // 60).zfill(2),
+                str(int(self.stop_time - self.start_time) % 60).zfill(2))
         except Exception:  # pylint: disable=broad-except
             self.__logger.error("Please run test before getting the duration")
             return "XX:XX"