summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Treinish <mtreinish@kortar.org>2015-01-07 10:52:24 -0500
committerMatthew Treinish <mtreinish@kortar.org>2015-01-07 11:11:31 -0500
commit87c1442469e76e338ee7eb0606e7e8caa525e056 (patch)
tree70321ee4e63902234aa77fd14f81ed3a31af5638
parentb73b9eb2a040a155e9f59d6da976fe2136532d44 (diff)
downloadtempest-lib-87c1442469e76e338ee7eb0606e7e8caa525e056.tar.gz
Fix subunit-trace on python < 2.70.0.4
This commit fixes running subunit-trace on older versions of python, by inlining the total_seconds method from newer versions of python. While tempest-lib is nominally only for python > 2.7 (which is all we test) subunit-trace is slightly different. Since it is expected to be used in the unit test workflows of projects, some of which still run on older python. Change-Id: I33c337bfb376a27bf02cc2d16a69dafba2cea41f
-rwxr-xr-xtempest_lib/cmd/subunit_trace.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/tempest_lib/cmd/subunit_trace.py b/tempest_lib/cmd/subunit_trace.py
index 64e1537..ea59cc6 100755
--- a/tempest_lib/cmd/subunit_trace.py
+++ b/tempest_lib/cmd/subunit_trace.py
@@ -33,6 +33,13 @@ FAILS = []
RESULTS = {}
+def total_seconds(timedelta):
+ # NOTE(mtreinish): This method is built-in to the timedelta class in
+ # python >= 2.7 it is here to enable it's use on older versions
+ return ((timedelta.days * DAY_SECONDS + timedelta.seconds) * 10 ** 6 +
+ timedelta.microseconds) / 10 ** 6
+
+
def cleanup_test_name(name, strip_tags=True, strip_scenarios=False):
"""Clean up the test name for display.
@@ -192,7 +199,7 @@ def worker_stats(worker):
def print_summary(stream, elapsed_time):
stream.write("\n======\nTotals\n======\n")
stream.write("Ran: %s tests in %.4f sec.\n" % (
- count_tests('status', '.*'), elapsed_time.total_seconds()))
+ count_tests('status', '.*'), total_seconds(elapsed_time)))
stream.write(" - Passed: %s\n" % count_tests('status', 'success'))
stream.write(" - Skipped: %s\n" % count_tests('status', 'skip'))
stream.write(" - Failed: %s\n" % count_tests('status', 'fail'))