* [PATCH 0/2] OEQA loader improvement
@ 2017-02-10 14:15 mariano.lopez
2017-02-10 14:15 ` [PATCH 1/2] oeqa/core/loader.py: Give meaningful error when failed to load classes mariano.lopez
2017-02-10 14:15 ` [PATCH 2/2] oeqa/core/loader.py: Avoid importing tests with built-ins name mariano.lopez
0 siblings, 2 replies; 3+ messages in thread
From: mariano.lopez @ 2017-02-10 14:15 UTC (permalink / raw)
To: openembedded-core
From: Mariano Lopez <mariano.lopez@linux.intel.com>
The first adds more verbosity when a class doesn't inherit
from the expected test class.
The second patch raises an error when trying to import a test
with the same module name as a built-in module.
The following changes since commit e758547db9048d4aa1c1415d6af8072f519fae24:
nss: Fix nss-native so the checksum doesn't change with BUILD_ARCH (2017-02-09 10:52:03 +0000)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib mariano/bug10978
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=mariano/bug10978
Mariano Lopez (2):
oeqa/core/loader.py: Give meaningful error when failed to load classes
oeqa/core/loader.py: Avoid importing tests with built-ins name
meta/lib/oeqa/core/loader.py | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
--
2.6.6
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] oeqa/core/loader.py: Give meaningful error when failed to load classes
2017-02-10 14:15 [PATCH 0/2] OEQA loader improvement mariano.lopez
@ 2017-02-10 14:15 ` mariano.lopez
2017-02-10 14:15 ` [PATCH 2/2] oeqa/core/loader.py: Avoid importing tests with built-ins name mariano.lopez
1 sibling, 0 replies; 3+ messages in thread
From: mariano.lopez @ 2017-02-10 14:15 UTC (permalink / raw)
To: openembedded-core
From: Mariano Lopez <mariano.lopez@linux.intel.com>
With this we get the class that is actually having the problem,
not just a TypeError with an unknown class causing the error.
Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
---
meta/lib/oeqa/core/loader.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/meta/lib/oeqa/core/loader.py b/meta/lib/oeqa/core/loader.py
index c73ef9a..bf13a5a 100644
--- a/meta/lib/oeqa/core/loader.py
+++ b/meta/lib/oeqa/core/loader.py
@@ -171,10 +171,11 @@ class OETestLoader(unittest.TestLoader):
"""
if issubclass(testCaseClass, unittest.suite.TestSuite):
raise TypeError("Test cases should not be derived from TestSuite." \
- " Maybe you meant to derive from TestCase?")
+ " Maybe you meant to derive %s from TestCase?" \
+ % testCaseClass.__name__)
if not issubclass(testCaseClass, self.caseClass):
- raise TypeError("Test cases need to be derived from %s" % \
- caseClass.__name__)
+ raise TypeError("Test %s is not derived from %s" % \
+ (testCaseClass.__name__, self.caseClass.__name__))
testCaseNames = self.getTestCaseNames(testCaseClass)
--
2.6.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] oeqa/core/loader.py: Avoid importing tests with built-ins name
2017-02-10 14:15 [PATCH 0/2] OEQA loader improvement mariano.lopez
2017-02-10 14:15 ` [PATCH 1/2] oeqa/core/loader.py: Give meaningful error when failed to load classes mariano.lopez
@ 2017-02-10 14:15 ` mariano.lopez
1 sibling, 0 replies; 3+ messages in thread
From: mariano.lopez @ 2017-02-10 14:15 UTC (permalink / raw)
To: openembedded-core
From: Mariano Lopez <mariano.lopez@linux.intel.com>
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]
Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
---
meta/lib/oeqa/core/loader.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/meta/lib/oeqa/core/loader.py b/meta/lib/oeqa/core/loader.py
index bf13a5a..a28512b 100644
--- a/meta/lib/oeqa/core/loader.py
+++ b/meta/lib/oeqa/core/loader.py
@@ -217,6 +217,13 @@ class OETestLoader(unittest.TestLoader):
# use_load_tests deprecation via *args and **kws. See issue 16662.
if sys.version_info >= (3,5):
def loadTestsFromModule(self, module, *args, pattern=None, **kws):
+ """
+ Returns a suite of all tests cases contained in module.
+ """
+ if module.__name__ in sys.builtin_module_names:
+ msg = 'Tried to import %s test module but is a built-in'
+ raise ImportError(msg % module.__name__)
+
if not self.modules or "all" in self.modules or \
module.__name__ in self.modules:
return super(OETestLoader, self).loadTestsFromModule(
@@ -228,6 +235,10 @@ class OETestLoader(unittest.TestLoader):
"""
Returns a suite of all tests cases contained in module.
"""
+ if module.__name__ in sys.builtin_module_names:
+ msg = 'Tried to import %s test module but is a built-in'
+ raise ImportError(msg % module.__name__)
+
if not self.modules or "all" in self.modules or \
module.__name__ in self.modules:
return super(OETestLoader, self).loadTestsFromModule(
--
2.6.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-02-10 22:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-10 14:15 [PATCH 0/2] OEQA loader improvement mariano.lopez
2017-02-10 14:15 ` [PATCH 1/2] oeqa/core/loader.py: Give meaningful error when failed to load classes mariano.lopez
2017-02-10 14:15 ` [PATCH 2/2] oeqa/core/loader.py: Avoid importing tests with built-ins name mariano.lopez
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.