diff options
| -rw-r--r-- | meta/lib/oeqa/core/loader.py | 70 |
1 files changed, 34 insertions, 36 deletions
diff --git a/meta/lib/oeqa/core/loader.py b/meta/lib/oeqa/core/loader.py index 7cc4d4c0cf..166fc35b4f 100644 --- a/meta/lib/oeqa/core/loader.py +++ b/meta/lib/oeqa/core/loader.py | |||
| @@ -164,8 +164,11 @@ class OETestLoader(unittest.TestLoader): | |||
| 164 | """ | 164 | """ |
| 165 | Returns True if test case must be filtered, False otherwise. | 165 | Returns True if test case must be filtered, False otherwise. |
| 166 | """ | 166 | """ |
| 167 | # Filters by module.class.name | 167 | # XXX; If the module has more than one namespace only use |
| 168 | module_name = case.__module__ | 168 | # the first to support run the whole module specifying the |
| 169 | # <module_name>.[test_class].[test_name] | ||
| 170 | module_name = case.__module__.split('.')[0] | ||
| 171 | |||
| 169 | class_name = case.__class__.__name__ | 172 | class_name = case.__class__.__name__ |
| 170 | test_name = case._testMethodName | 173 | test_name = case._testMethodName |
| 171 | 174 | ||
| @@ -278,6 +281,33 @@ class OETestLoader(unittest.TestLoader): | |||
| 278 | 281 | ||
| 279 | return self.suiteClass(cases) if cases else big_suite | 282 | return self.suiteClass(cases) if cases else big_suite |
| 280 | 283 | ||
| 284 | def _filterModule(self, module): | ||
| 285 | if module.__name__ in sys.builtin_module_names: | ||
| 286 | msg = 'Tried to import %s test module but is a built-in' | ||
| 287 | raise ImportError(msg % module.__name__) | ||
| 288 | |||
| 289 | # XXX; If the module has more than one namespace only use | ||
| 290 | # the first to support run the whole module specifying the | ||
| 291 | # <module_name>.[test_class].[test_name] | ||
| 292 | module_name = module.__name__.split('.')[0] | ||
| 293 | |||
| 294 | # Normal test modules are loaded if no modules were specified, | ||
| 295 | # if module is in the specified module list or if 'all' is in | ||
| 296 | # module list. | ||
| 297 | # Underscore modules are loaded only if specified in module list. | ||
| 298 | load_module = True if not module_name.startswith('_') \ | ||
| 299 | and (not self.modules \ | ||
| 300 | or module_name in self.modules \ | ||
| 301 | or 'all' in self.modules) \ | ||
| 302 | else False | ||
| 303 | |||
| 304 | load_underscore = True if module_name.startswith('_') \ | ||
| 305 | and module_name in self.modules \ | ||
| 306 | else False | ||
| 307 | |||
| 308 | return (load_module, load_underscore) | ||
| 309 | |||
| 310 | |||
| 281 | # XXX After Python 3.5, remove backward compatibility hacks for | 311 | # XXX After Python 3.5, remove backward compatibility hacks for |
| 282 | # use_load_tests deprecation via *args and **kws. See issue 16662. | 312 | # use_load_tests deprecation via *args and **kws. See issue 16662. |
| 283 | if sys.version_info >= (3,5): | 313 | if sys.version_info >= (3,5): |
| @@ -285,23 +315,7 @@ class OETestLoader(unittest.TestLoader): | |||
| 285 | """ | 315 | """ |
| 286 | Returns a suite of all tests cases contained in module. | 316 | Returns a suite of all tests cases contained in module. |
| 287 | """ | 317 | """ |
| 288 | if module.__name__ in sys.builtin_module_names: | 318 | load_module, load_underscore = self._filterModule(module) |
| 289 | msg = 'Tried to import %s test module but is a built-in' | ||
| 290 | raise ImportError(msg % module.__name__) | ||
| 291 | |||
| 292 | # Normal test modules are loaded if no modules were specified, | ||
| 293 | # if module is in the specified module list or if 'all' is in | ||
| 294 | # module list. | ||
| 295 | # Underscore modules are loaded only if specified in module list. | ||
| 296 | load_module = True if not module.__name__.startswith('_') \ | ||
| 297 | and (not self.modules \ | ||
| 298 | or module.__name__ in self.modules \ | ||
| 299 | or 'all' in self.modules) \ | ||
| 300 | else False | ||
| 301 | |||
| 302 | load_underscore = True if module.__name__.startswith('_') \ | ||
| 303 | and module.__name__ in self.modules \ | ||
| 304 | else False | ||
| 305 | 319 | ||
| 306 | if load_module or load_underscore: | 320 | if load_module or load_underscore: |
| 307 | return super(OETestLoader, self).loadTestsFromModule( | 321 | return super(OETestLoader, self).loadTestsFromModule( |
| @@ -313,23 +327,7 @@ class OETestLoader(unittest.TestLoader): | |||
| 313 | """ | 327 | """ |
| 314 | Returns a suite of all tests cases contained in module. | 328 | Returns a suite of all tests cases contained in module. |
| 315 | """ | 329 | """ |
| 316 | if module.__name__ in sys.builtin_module_names: | 330 | load_module, load_underscore = self._filterModule(module) |
| 317 | msg = 'Tried to import %s test module but is a built-in' | ||
| 318 | raise ImportError(msg % module.__name__) | ||
| 319 | |||
| 320 | # Normal test modules are loaded if no modules were specified, | ||
| 321 | # if module is in the specified module list or if 'all' is in | ||
| 322 | # module list. | ||
| 323 | # Underscore modules are loaded only if specified in module list. | ||
| 324 | load_module = True if not module.__name__.startswith('_') \ | ||
| 325 | and (not self.modules \ | ||
| 326 | or module.__name__ in self.modules \ | ||
| 327 | or 'all' in self.modules) \ | ||
| 328 | else False | ||
| 329 | |||
| 330 | load_underscore = True if module.__name__.startswith('_') \ | ||
| 331 | and module.__name__ in self.modules \ | ||
| 332 | else False | ||
| 333 | 331 | ||
| 334 | if load_module or load_underscore: | 332 | if load_module or load_underscore: |
| 335 | return super(OETestLoader, self).loadTestsFromModule( | 333 | return super(OETestLoader, self).loadTestsFromModule( |
