diff options
Diffstat (limited to 'meta/lib/oeqa/utils')
-rw-r--r-- | meta/lib/oeqa/utils/decorators.py | 40 |
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 | ||
9 | from oeqa.oetest import * | ||
10 | import logging | 9 | import logging |
11 | import sys | 10 | import sys |
11 | import 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 | ||
14 | class 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 | ||
13 | class skipIfFailure(object): | 38 | class 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__ |