[Piglit] [PATCH 1/2] framework/results.py: Copy 'tests' internally to OrderedDict
Tomi Sarvela
tomi.p.sarvela at intel.com
Thu Feb 9 11:07:04 UTC 2017
To preserve the original test running order, use OrderedDict
when copying 'tests' values over.
---
framework/results.py | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/framework/results.py b/framework/results.py
index 1a73c11..45a5727 100644
--- a/framework/results.py
+++ b/framework/results.py
@@ -24,7 +24,9 @@
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
-import collections
+from collections import defaultdict
+from collections import OrderedDict
+from collections import MutableMapping
import copy
import datetime
@@ -38,7 +40,7 @@ __all__ = [
]
-class Subtests(collections.MutableMapping):
+class Subtests(MutableMapping):
"""A dict-like object that stores Statuses as values."""
def __init__(self, dict_=None):
self.__container = {}
@@ -301,8 +303,8 @@ class TestrunResult(object):
self.clinfo = None
self.lspci = None
self.time_elapsed = TimeAttribute()
- self.tests = collections.OrderedDict()
- self.totals = collections.defaultdict(Totals)
+ self.tests = OrderedDict()
+ self.totals = defaultdict(Totals)
def get_result(self, key):
"""Get the result of a test or subtest.
@@ -350,7 +352,7 @@ class TestrunResult(object):
if not self.totals:
self.calculate_group_totals()
rep = copy.copy(self.__dict__)
- rep['tests'] = {k: t.to_json() for k, t in six.iteritems(self.tests)}
+ rep['tests'] = OrderedDict([ ( k, t.to_json() ) for k, t in six.iteritems(self.tests)] )
rep['__type__'] = 'TestrunResult'
return rep
@@ -378,8 +380,8 @@ class TestrunResult(object):
if 'time_elapsed' in dict_:
setattr(res, 'time_elapsed',
TimeAttribute.from_dict(dict_['time_elapsed']))
- res.tests = {n: TestResult.from_dict(t)
- for n, t in six.iteritems(dict_['tests'])}
+ res.tests = OrderedDict([ (n, TestResult.from_dict(t))
+ for n, t in six.iteritems(dict_['tests']) ])
if not 'totals' in dict_ and not _no_totals:
res.calculate_group_totals()
--
2.9.3
More information about the Piglit
mailing list