summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils
diff options
context:
space:
mode:
authorLucian Musat <georgex.l.musat@intel.com>2014-07-24 15:41:24 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-07-25 15:34:00 +0100
commit0c4dd0ad168e138ba96eaf27aa7e513aaf6704ee (patch)
tree04108e45fe1750a44b72ca1650f4cb8e1d466369 /meta/lib/oeqa/utils
parent0565d8bc17b061a8a6087f1667e10a3e3608c88e (diff)
downloadpoky-0c4dd0ad168e138ba96eaf27aa7e513aaf6704ee.tar.gz
oeqa: Refactor test skipping decorators to use the unittest result object
In order to make the test skipping decorators independent of the oeTest object we rely on the unittest result object to construct skip, fail and error lists used by these decorators. Created a new object getResults that analyses upper frames and retrieves the unittest result object instance, then return a list of failed, skipped and error tests. Also removed the oetest import from decorators.py because it was no longer required. (From OE-Core rev: 4d2d201158236bd4c72546cf8db88681ff921b11) Signed-off-by: Lucian Musat <georgex.l.musat@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils')
-rw-r--r--meta/lib/oeqa/utils/decorators.py40
1 files changed, 34 insertions, 6 deletions
diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py
index a0d94e6d24..439e80a42b 100644
--- a/meta/lib/oeqa/utils/decorators.py
+++ b/meta/lib/oeqa/utils/decorators.py
@@ -6,9 +6,34 @@
6# Most useful is skipUnlessPassed which can be used for 6# Most useful is skipUnlessPassed which can be used for
7# creating dependecies between two test methods. 7# creating dependecies between two test methods.
8 8
9from oeqa.oetest import *
10import logging 9import logging
11import sys 10import sys
11import unittest
12
13#get the "result" object from one of the upper frames provided that one of these upper frames is a unittest.case frame
14class getResults(object):
15 def __init__(self):
16 #dynamically determine the unittest.case frame and use it to get the name of the test method
17 upperf = sys._current_frames().values()[0]
18 while (upperf.f_globals['__name__'] != 'unittest.case'):
19 upperf = upperf.f_back
20 self.faillist = [ seq[0]._testMethodName for seq in upperf.f_locals['result'].failures ]
21 self.errorlist = [ seq[0]._testMethodName for seq in upperf.f_locals['result'].errors ]
22 #ignore the _ErrorHolder objects from the skipped tests list
23 self.skiplist = []
24 for seq in upperf.f_locals['result'].skipped:
25 try:
26 self.skiplist.append(seq[0]._testMethodName)
27 except: pass
28
29 def getFailList(self):
30 return self.faillist
31
32 def getErrorList(self):
33 return self.errorlist
34
35 def getSkipList(self):
36 return self.skiplist
12 37
13class skipIfFailure(object): 38class skipIfFailure(object):
14 39
@@ -17,7 +42,8 @@ class skipIfFailure(object):
17 42
18 def __call__(self,f): 43 def __call__(self,f):
19 def wrapped_f(*args): 44 def wrapped_f(*args):
20 if self.testcase in (oeTest.testFailures or oeTest.testErrors): 45 res = getResults()
46 if self.testcase in (res.getFailList() or res.getErrorList()):
21 raise unittest.SkipTest("Testcase dependency not met: %s" % self.testcase) 47 raise unittest.SkipTest("Testcase dependency not met: %s" % self.testcase)
22 return f(*args) 48 return f(*args)
23 wrapped_f.__name__ = f.__name__ 49 wrapped_f.__name__ = f.__name__
@@ -30,7 +56,8 @@ class skipIfSkipped(object):
30 56
31 def __call__(self,f): 57 def __call__(self,f):
32 def wrapped_f(*args): 58 def wrapped_f(*args):
33 if self.testcase in oeTest.testSkipped: 59 res = getResults()
60 if self.testcase in res.getSkipList():
34 raise unittest.SkipTest("Testcase dependency not met: %s" % self.testcase) 61 raise unittest.SkipTest("Testcase dependency not met: %s" % self.testcase)
35 return f(*args) 62 return f(*args)
36 wrapped_f.__name__ = f.__name__ 63 wrapped_f.__name__ = f.__name__
@@ -43,9 +70,10 @@ class skipUnlessPassed(object):
43 70
44 def __call__(self,f): 71 def __call__(self,f):
45 def wrapped_f(*args): 72 def wrapped_f(*args):
46 if self.testcase in oeTest.testSkipped or \ 73 res = getResults()
47 self.testcase in oeTest.testFailures or \ 74 if self.testcase in res.getSkipList() or \
48 self.testcase in oeTest.testErrors: 75 self.testcase in res.getFailList() or \
76 self.testcase in res.getErrorList():
49 raise unittest.SkipTest("Testcase dependency not met: %s" % self.testcase) 77 raise unittest.SkipTest("Testcase dependency not met: %s" % self.testcase)
50 return f(*args) 78 return f(*args)
51 wrapped_f.__name__ = f.__name__ 79 wrapped_f.__name__ = f.__name__