summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/core
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2017-06-08 11:32:05 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-12 15:08:30 +0100
commit0b168b269b497383d01e71db585235948b71a3f8 (patch)
tree3241000fd819712855e921d0848460c551d67931 /meta/lib/oeqa/core
parentc3587b7d1005c8564e54263768d0088afbb5c946 (diff)
downloadpoky-0b168b269b497383d01e71db585235948b71a3f8.tar.gz
oeqa/core/loader: Allow unittest.TestCase's to be executed
Currently there was a restriction to only execute tests that's inherits from OETestCase but in some circunstancies the features from the OEQA framework isn't needed so we need to support basic unittests. [YOCTO #10828] (From OE-Core rev: baac26f1b36e89e07637b738dd31ec7356f05a02) Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/core')
-rw-r--r--meta/lib/oeqa/core/loader.py12
-rw-r--r--meta/lib/oeqa/core/runner.py25
2 files changed, 21 insertions, 16 deletions
diff --git a/meta/lib/oeqa/core/loader.py b/meta/lib/oeqa/core/loader.py
index 166fc35b4f..d110881698 100644
--- a/meta/lib/oeqa/core/loader.py
+++ b/meta/lib/oeqa/core/loader.py
@@ -185,7 +185,7 @@ class OETestLoader(unittest.TestLoader):
185 return True 185 return True
186 186
187 # Decorator filters 187 # Decorator filters
188 if self.filters: 188 if self.filters and isinstance(case, OETestCase):
189 filters = self.filters.copy() 189 filters = self.filters.copy()
190 case_decorators = [cd for cd in case.decorators 190 case_decorators = [cd for cd in case.decorators
191 if cd.__class__ in self.used_filters] 191 if cd.__class__ in self.used_filters]
@@ -203,7 +203,8 @@ class OETestLoader(unittest.TestLoader):
203 return False 203 return False
204 204
205 def _getTestCase(self, testCaseClass, tcName): 205 def _getTestCase(self, testCaseClass, tcName):
206 if not hasattr(testCaseClass, '__oeqa_loader'): 206 if not hasattr(testCaseClass, '__oeqa_loader') and \
207 issubclass(testCaseClass, OETestCase):
207 # In order to support data_vars validation 208 # In order to support data_vars validation
208 # monkey patch the default setUp/tearDown{Class} to use 209 # monkey patch the default setUp/tearDown{Class} to use
209 # the ones provided by OETestCase 210 # the ones provided by OETestCase
@@ -230,7 +231,8 @@ class OETestLoader(unittest.TestLoader):
230 setattr(testCaseClass, '__oeqa_loader', True) 231 setattr(testCaseClass, '__oeqa_loader', True)
231 232
232 case = testCaseClass(tcName) 233 case = testCaseClass(tcName)
233 setattr(case, 'decorators', []) 234 if isinstance(case, OETestCase):
235 setattr(case, 'decorators', [])
234 236
235 return case 237 return case
236 238
@@ -242,9 +244,9 @@ class OETestLoader(unittest.TestLoader):
242 raise TypeError("Test cases should not be derived from TestSuite." \ 244 raise TypeError("Test cases should not be derived from TestSuite." \
243 " Maybe you meant to derive %s from TestCase?" \ 245 " Maybe you meant to derive %s from TestCase?" \
244 % testCaseClass.__name__) 246 % testCaseClass.__name__)
245 if not issubclass(testCaseClass, self.caseClass): 247 if not issubclass(testCaseClass, unittest.case.TestCase):
246 raise TypeError("Test %s is not derived from %s" % \ 248 raise TypeError("Test %s is not derived from %s" % \
247 (testCaseClass.__name__, self.caseClass.__name__)) 249 (testCaseClass.__name__, unittest.case.TestCase.__name__))
248 250
249 testCaseNames = self.getTestCaseNames(testCaseClass) 251 testCaseNames = self.getTestCaseNames(testCaseClass)
250 if not testCaseNames and hasattr(testCaseClass, 'runTest'): 252 if not testCaseNames and hasattr(testCaseClass, 'runTest'):
diff --git a/meta/lib/oeqa/core/runner.py b/meta/lib/oeqa/core/runner.py
index 7ce718e784..532b25b98a 100644
--- a/meta/lib/oeqa/core/runner.py
+++ b/meta/lib/oeqa/core/runner.py
@@ -121,9 +121,10 @@ class OETestResult(_TestResult):
121 break 121 break
122 122
123 oeid = -1 123 oeid = -1
124 for d in case.decorators: 124 if hasattr(case, 'decorators'):
125 if hasattr(d, 'oeid'): 125 for d in case.decorators:
126 oeid = d.oeid 126 if hasattr(d, 'oeid'):
127 oeid = d.oeid
127 128
128 if fail: 129 if fail:
129 self.tc.logger.info("RESULTS - %s - Testcase %s: %s" % (case.id(), 130 self.tc.logger.info("RESULTS - %s - Testcase %s: %s" % (case.id(),
@@ -188,9 +189,10 @@ class OETestRunner(_TestRunner):
188 def _list_cases_without_id(logger, case): 189 def _list_cases_without_id(logger, case):
189 190
190 found_id = False 191 found_id = False
191 for d in case.decorators: 192 if hasattr(case, 'decorators'):
192 if isinstance(d, OETestID): 193 for d in case.decorators:
193 found_id = True 194 if isinstance(d, OETestID):
195 found_id = True
194 196
195 if not found_id: 197 if not found_id:
196 logger.info('oeid missing for %s' % case.id()) 198 logger.info('oeid missing for %s' % case.id())
@@ -199,11 +201,12 @@ class OETestRunner(_TestRunner):
199 oeid = None 201 oeid = None
200 oetag = None 202 oetag = None
201 203
202 for d in case.decorators: 204 if hasattr(case, 'decorators'):
203 if isinstance(d, OETestID): 205 for d in case.decorators:
204 oeid = d.oeid 206 if isinstance(d, OETestID):
205 elif isinstance(d, OETestTag): 207 oeid = d.oeid
206 oetag = d.oetag 208 elif isinstance(d, OETestTag):
209 oetag = d.oetag
207 210
208 logger.info("%s\t%s\t\t%s" % (oeid, oetag, case.id())) 211 logger.info("%s\t%s\t\t%s" % (oeid, oetag, case.id()))
209 212