summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/core/loader.py
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/loader.py
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/loader.py')
-rw-r--r--meta/lib/oeqa/core/loader.py12
1 files changed, 7 insertions, 5 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'):