summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorMariano Lopez <mariano.lopez@linux.intel.com>2017-02-27 07:45:01 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-01 23:27:10 +0000
commit661c73b716aced4728659ac02ab63c83fa232c8c (patch)
treed196cb3d201e9e205f8f6fd93246898fef12e7f5 /meta
parent9f8748c59fe418b1f386854d8df71142a789822b (diff)
downloadpoky-661c73b716aced4728659ac02ab63c83fa232c8c.tar.gz
oeqa/core/loader.py: Avoid importing tests with built-ins name
If importing a test with the same name as a built-in module, it will silently import the built-in and check for tests in built-in module. This happened with syslog module in debian based machines, so add a raise to avoid this behavior. [YOCTO #10978] (From OE-Core rev: d9548f981448307b042807373e469f0d0b110bfe) Signed-off-by: Mariano Lopez <mariano.lopez@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')
-rw-r--r--meta/lib/oeqa/core/loader.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/meta/lib/oeqa/core/loader.py b/meta/lib/oeqa/core/loader.py
index b9ba9235af..74f1117825 100644
--- a/meta/lib/oeqa/core/loader.py
+++ b/meta/lib/oeqa/core/loader.py
@@ -216,6 +216,13 @@ class OETestLoader(unittest.TestLoader):
216 # use_load_tests deprecation via *args and **kws. See issue 16662. 216 # use_load_tests deprecation via *args and **kws. See issue 16662.
217 if sys.version_info >= (3,5): 217 if sys.version_info >= (3,5):
218 def loadTestsFromModule(self, module, *args, pattern=None, **kws): 218 def loadTestsFromModule(self, module, *args, pattern=None, **kws):
219 """
220 Returns a suite of all tests cases contained in module.
221 """
222 if module.__name__ in sys.builtin_module_names:
223 msg = 'Tried to import %s test module but is a built-in'
224 raise ImportError(msg % module.__name__)
225
219 if not self.modules or "all" in self.modules or \ 226 if not self.modules or "all" in self.modules or \
220 module.__name__ in self.modules: 227 module.__name__ in self.modules:
221 return super(OETestLoader, self).loadTestsFromModule( 228 return super(OETestLoader, self).loadTestsFromModule(
@@ -227,6 +234,10 @@ class OETestLoader(unittest.TestLoader):
227 """ 234 """
228 Returns a suite of all tests cases contained in module. 235 Returns a suite of all tests cases contained in module.
229 """ 236 """
237 if module.__name__ in sys.builtin_module_names:
238 msg = 'Tried to import %s test module but is a built-in'
239 raise ImportError(msg % module.__name__)
240
230 if not self.modules or "all" in self.modules or \ 241 if not self.modules or "all" in self.modules or \
231 module.__name__ in self.modules: 242 module.__name__ in self.modules:
232 return super(OETestLoader, self).loadTestsFromModule( 243 return super(OETestLoader, self).loadTestsFromModule(