summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/lib/oeqa/core/utils/concurrencytest.py31
1 files changed, 18 insertions, 13 deletions
diff --git a/meta/lib/oeqa/core/utils/concurrencytest.py b/meta/lib/oeqa/core/utils/concurrencytest.py
index 6293cf94ec..0f7b3dcc11 100644
--- a/meta/lib/oeqa/core/utils/concurrencytest.py
+++ b/meta/lib/oeqa/core/utils/concurrencytest.py
@@ -78,29 +78,29 @@ class ProxyTestResult:
78 def __init__(self, target): 78 def __init__(self, target):
79 self.result = target 79 self.result = target
80 80
81 def _addResult(self, method, test, *args, **kwargs): 81 def _addResult(self, method, test, *args, exception = False, **kwargs):
82 return method(test, *args, **kwargs) 82 return method(test, *args, **kwargs)
83 83
84 def addError(self, test, *args, **kwargs): 84 def addError(self, test, err = None, **kwargs):
85 self._addResult(self.result.addError, test, *args, **kwargs) 85 self._addResult(self.result.addError, test, err, exception = True, **kwargs)
86 86
87 def addFailure(self, test, *args, **kwargs): 87 def addFailure(self, test, err = None, **kwargs):
88 self._addResult(self.result.addFailure, test, *args, **kwargs) 88 self._addResult(self.result.addFailure, test, err, exception = True, **kwargs)
89 89
90 def addSuccess(self, test, *args, **kwargs): 90 def addSuccess(self, test, **kwargs):
91 self._addResult(self.result.addSuccess, test, *args, **kwargs) 91 self._addResult(self.result.addSuccess, test, **kwargs)
92 92
93 def addExpectedFailure(self, test, *args, **kwargs): 93 def addExpectedFailure(self, test, err = None, **kwargs):
94 self._addResult(self.result.addExpectedFailure, test, *args, **kwargs) 94 self._addResult(self.result.addExpectedFailure, test, err, exception = True, **kwargs)
95 95
96 def addUnexpectedSuccess(self, test, *args, **kwargs): 96 def addUnexpectedSuccess(self, test, **kwargs):
97 self._addResult(self.result.addUnexpectedSuccess, test, *args, **kwargs) 97 self._addResult(self.result.addUnexpectedSuccess, test, **kwargs)
98 98
99 def __getattr__(self, attr): 99 def __getattr__(self, attr):
100 return getattr(self.result, attr) 100 return getattr(self.result, attr)
101 101
102class ExtraResultsDecoderTestResult(ProxyTestResult): 102class ExtraResultsDecoderTestResult(ProxyTestResult):
103 def _addResult(self, method, test, *args, **kwargs): 103 def _addResult(self, method, test, *args, exception = False, **kwargs):
104 if "details" in kwargs and "extraresults" in kwargs["details"]: 104 if "details" in kwargs and "extraresults" in kwargs["details"]:
105 if isinstance(kwargs["details"]["extraresults"], Content): 105 if isinstance(kwargs["details"]["extraresults"], Content):
106 kwargs = kwargs.copy() 106 kwargs = kwargs.copy()
@@ -114,7 +114,7 @@ class ExtraResultsDecoderTestResult(ProxyTestResult):
114 return method(test, *args, **kwargs) 114 return method(test, *args, **kwargs)
115 115
116class ExtraResultsEncoderTestResult(ProxyTestResult): 116class ExtraResultsEncoderTestResult(ProxyTestResult):
117 def _addResult(self, method, test, *args, **kwargs): 117 def _addResult(self, method, test, *args, exception = False, **kwargs):
118 if hasattr(test, "extraresults"): 118 if hasattr(test, "extraresults"):
119 extras = lambda : [json.dumps(test.extraresults).encode()] 119 extras = lambda : [json.dumps(test.extraresults).encode()]
120 kwargs = kwargs.copy() 120 kwargs = kwargs.copy()
@@ -123,6 +123,11 @@ class ExtraResultsEncoderTestResult(ProxyTestResult):
123 else: 123 else:
124 kwargs["details"] = kwargs["details"].copy() 124 kwargs["details"] = kwargs["details"].copy()
125 kwargs["details"]["extraresults"] = Content(ContentType("application", "json", {'charset': 'utf8'}), extras) 125 kwargs["details"]["extraresults"] = Content(ContentType("application", "json", {'charset': 'utf8'}), extras)
126 # if using details, need to encode any exceptions into the details obj,
127 # testtools does not handle "err" and "details" together.
128 if "details" in kwargs and exception and (len(args) >= 1 and args[0] is not None):
129 kwargs["details"]["traceback"] = testtools.content.TracebackContent(args[0], test)
130 args = []
126 return method(test, *args, **kwargs) 131 return method(test, *args, **kwargs)
127 132
128# 133#