mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 13:09:50 +00:00
oetest.py: Move getTests() outside loadTests() method
The method getTests() can be useful to all the class, not just to loadTests(). [YOCTO #8694] (From OE-Core rev: 667a4549bd51a6e4b487006f4cc1542d2961757a) 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>
This commit is contained in:
committed by
Richard Purdie
parent
549f134970
commit
daf0cc3745
+18
-18
@@ -264,6 +264,22 @@ class TestContext(object):
|
|||||||
|
|
||||||
return testslist
|
return testslist
|
||||||
|
|
||||||
|
def getTests(self, test):
|
||||||
|
'''Return all individual tests executed when running the suite.'''
|
||||||
|
# Unfortunately unittest does not have an API for this, so we have
|
||||||
|
# to rely on implementation details. This only needs to work
|
||||||
|
# for TestSuite containing TestCase.
|
||||||
|
method = getattr(test, '_testMethodName', None)
|
||||||
|
if method:
|
||||||
|
# leaf case: a TestCase
|
||||||
|
yield test
|
||||||
|
else:
|
||||||
|
# Look into TestSuite.
|
||||||
|
tests = getattr(test, '_tests', [])
|
||||||
|
for t1 in tests:
|
||||||
|
for t2 in self.getTests(t1):
|
||||||
|
yield t2
|
||||||
|
|
||||||
def loadTests(self):
|
def loadTests(self):
|
||||||
setattr(oeTest, "tc", self)
|
setattr(oeTest, "tc", self)
|
||||||
|
|
||||||
@@ -272,36 +288,20 @@ class TestContext(object):
|
|||||||
suites = [testloader.loadTestsFromName(name) for name in self.testslist]
|
suites = [testloader.loadTestsFromName(name) for name in self.testslist]
|
||||||
suites = filterByTagExp(suites, getattr(self, "tagexp", None))
|
suites = filterByTagExp(suites, getattr(self, "tagexp", None))
|
||||||
|
|
||||||
def getTests(test):
|
|
||||||
'''Return all individual tests executed when running the suite.'''
|
|
||||||
# Unfortunately unittest does not have an API for this, so we have
|
|
||||||
# to rely on implementation details. This only needs to work
|
|
||||||
# for TestSuite containing TestCase.
|
|
||||||
method = getattr(test, '_testMethodName', None)
|
|
||||||
if method:
|
|
||||||
# leaf case: a TestCase
|
|
||||||
yield test
|
|
||||||
else:
|
|
||||||
# Look into TestSuite.
|
|
||||||
tests = getattr(test, '_tests', [])
|
|
||||||
for t1 in tests:
|
|
||||||
for t2 in getTests(t1):
|
|
||||||
yield t2
|
|
||||||
|
|
||||||
# Determine dependencies between suites by looking for @skipUnlessPassed
|
# Determine dependencies between suites by looking for @skipUnlessPassed
|
||||||
# method annotations. Suite A depends on suite B if any method in A
|
# method annotations. Suite A depends on suite B if any method in A
|
||||||
# depends on a method on B.
|
# depends on a method on B.
|
||||||
for suite in suites:
|
for suite in suites:
|
||||||
suite.dependencies = []
|
suite.dependencies = []
|
||||||
suite.depth = 0
|
suite.depth = 0
|
||||||
for test in getTests(suite):
|
for test in self.getTests(suite):
|
||||||
methodname = getattr(test, '_testMethodName', None)
|
methodname = getattr(test, '_testMethodName', None)
|
||||||
if methodname:
|
if methodname:
|
||||||
method = getattr(test, methodname)
|
method = getattr(test, methodname)
|
||||||
depends_on = getattr(method, '_depends_on', None)
|
depends_on = getattr(method, '_depends_on', None)
|
||||||
if depends_on:
|
if depends_on:
|
||||||
for dep_suite in suites:
|
for dep_suite in suites:
|
||||||
if depends_on in [getattr(t, '_testMethodName', None) for t in getTests(dep_suite)]:
|
if depends_on in [getattr(t, '_testMethodName', None) for t in self.getTests(dep_suite)]:
|
||||||
if dep_suite not in suite.dependencies and \
|
if dep_suite not in suite.dependencies and \
|
||||||
dep_suite is not suite:
|
dep_suite is not suite:
|
||||||
suite.dependencies.append(dep_suite)
|
suite.dependencies.append(dep_suite)
|
||||||
|
|||||||
Reference in New Issue
Block a user