From: "Aníbal Limón" <anibal.limon@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 5/7] oeqa/core/loader: Allow unittest.TestCase's to be executed
Date: Thu, 8 Jun 2017 11:32:05 -0500 [thread overview]
Message-ID: <95d0e1ec17fc218d14f29efaf9c37ae5cb4c41af.1496939387.git.anibal.limon@linux.intel.com> (raw)
In-Reply-To: <cover.1496939387.git.anibal.limon@linux.intel.com>
In-Reply-To: <cover.1496939387.git.anibal.limon@linux.intel.com>
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]
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
---
meta/lib/oeqa/core/loader.py | 12 +++++++-----
meta/lib/oeqa/core/runner.py | 25 ++++++++++++++-----------
2 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/meta/lib/oeqa/core/loader.py b/meta/lib/oeqa/core/loader.py
index 7cc4d4c..b9385ea 100644
--- a/meta/lib/oeqa/core/loader.py
+++ b/meta/lib/oeqa/core/loader.py
@@ -182,7 +182,7 @@ class OETestLoader(unittest.TestLoader):
return True
# Decorator filters
- if self.filters:
+ if self.filters and isinstance(case, OETestCase):
filters = self.filters.copy()
case_decorators = [cd for cd in case.decorators
if cd.__class__ in self.used_filters]
@@ -200,7 +200,8 @@ class OETestLoader(unittest.TestLoader):
return False
def _getTestCase(self, testCaseClass, tcName):
- if not hasattr(testCaseClass, '__oeqa_loader'):
+ if not hasattr(testCaseClass, '__oeqa_loader') and \
+ issubclass(testCaseClass, OETestCase):
# In order to support data_vars validation
# monkey patch the default setUp/tearDown{Class} to use
# the ones provided by OETestCase
@@ -227,7 +228,8 @@ class OETestLoader(unittest.TestLoader):
setattr(testCaseClass, '__oeqa_loader', True)
case = testCaseClass(tcName)
- setattr(case, 'decorators', [])
+ if isinstance(case, OETestCase):
+ setattr(case, 'decorators', [])
return case
@@ -239,9 +241,9 @@ class OETestLoader(unittest.TestLoader):
raise TypeError("Test cases should not be derived from TestSuite." \
" Maybe you meant to derive %s from TestCase?" \
% testCaseClass.__name__)
- if not issubclass(testCaseClass, self.caseClass):
+ if not issubclass(testCaseClass, unittest.case.TestCase):
raise TypeError("Test %s is not derived from %s" % \
- (testCaseClass.__name__, self.caseClass.__name__))
+ (testCaseClass.__name__, unittest.case.TestCase.__name__))
testCaseNames = self.getTestCaseNames(testCaseClass)
if not testCaseNames and hasattr(testCaseClass, 'runTest'):
diff --git a/meta/lib/oeqa/core/runner.py b/meta/lib/oeqa/core/runner.py
index 7ce718e..532b25b 100644
--- a/meta/lib/oeqa/core/runner.py
+++ b/meta/lib/oeqa/core/runner.py
@@ -121,9 +121,10 @@ class OETestResult(_TestResult):
break
oeid = -1
- for d in case.decorators:
- if hasattr(d, 'oeid'):
- oeid = d.oeid
+ if hasattr(case, 'decorators'):
+ for d in case.decorators:
+ if hasattr(d, 'oeid'):
+ oeid = d.oeid
if fail:
self.tc.logger.info("RESULTS - %s - Testcase %s: %s" % (case.id(),
@@ -188,9 +189,10 @@ class OETestRunner(_TestRunner):
def _list_cases_without_id(logger, case):
found_id = False
- for d in case.decorators:
- if isinstance(d, OETestID):
- found_id = True
+ if hasattr(case, 'decorators'):
+ for d in case.decorators:
+ if isinstance(d, OETestID):
+ found_id = True
if not found_id:
logger.info('oeid missing for %s' % case.id())
@@ -199,11 +201,12 @@ class OETestRunner(_TestRunner):
oeid = None
oetag = None
- for d in case.decorators:
- if isinstance(d, OETestID):
- oeid = d.oeid
- elif isinstance(d, OETestTag):
- oetag = d.oetag
+ if hasattr(case, 'decorators'):
+ for d in case.decorators:
+ if isinstance(d, OETestID):
+ oeid = d.oeid
+ elif isinstance(d, OETestTag):
+ oetag = d.oetag
logger.info("%s\t%s\t\t%s" % (oeid, oetag, case.id()))
--
2.1.4
next prev parent reply other threads:[~2017-06-08 16:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-08 16:32 [PATCH 0/7] OEQA, devtool and YP compatible fixes Aníbal Limón
2017-06-08 16:32 ` [PATCH 1/7] devtool/standard: Fix lock in _prep_extract_operation Aníbal Limón
2017-06-08 16:32 ` [PATCH 2/7] scripts/yocto-compat-layer.py: Return non-zero when layer test fail Aníbal Limón
2017-06-08 16:32 ` [PATCH 3/7] scripts/yocto-compat-layer-wrapper: Use realpath of output_log Aníbal Limón
2017-06-08 16:32 ` [PATCH 4/7] oeqa: Change the order to logDetails and logSummary Aníbal Limón
2017-06-08 16:32 ` Aníbal Limón [this message]
2017-06-08 16:32 ` [PATCH 6/7] oeqa/cases/oelib: Change default case class to unittest.case.TestCase Aníbal Limón
2017-06-08 16:32 ` [PATCH 7/7] oeqa/core/loader: Fix filtering on test modules with submodules Aníbal Limón
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=95d0e1ec17fc218d14f29efaf9c37ae5cb4c41af.1496939387.git.anibal.limon@linux.intel.com \
--to=anibal.limon@linux.intel.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox