diff options
| author | Radu Moisan <radu.moisan@intel.com> | 2013-06-28 11:28:57 +0300 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-07-09 10:53:45 +0100 |
| commit | 54f3848397640d3c6b6990bef727834bd364aa45 (patch) | |
| tree | 4061695a12988bf32c043539cb294834eae2eb2b | |
| parent | 88a6eb8027ae999fb53362d864301a3d525877d3 (diff) | |
| download | poky-54f3848397640d3c6b6990bef727834bd364aa45.tar.gz | |
lib/oeqa/utils/decorators.py: decorators for test methods
Some skip decorators meant only for test methods, providing
some kind of test methods dependency.
They are used together with a test method name not a condition.
These are complementary to python's unittest skip decorators.
(From OE-Core rev: 79cb89648702aa80ec986e0026c62948de905b87)
Signed-off-by: Radu Moisan <radu.moisan@intel.com>
Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/lib/oeqa/utils/decorators.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py new file mode 100644 index 0000000000..21e6b22cb9 --- /dev/null +++ b/meta/lib/oeqa/utils/decorators.py | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | from oeqa.oetest import * | ||
| 2 | |||
| 3 | class skipIfFailure(object): | ||
| 4 | |||
| 5 | def __init__(self,testcase): | ||
| 6 | self.testcase = testcase | ||
| 7 | |||
| 8 | def __call__(self,f): | ||
| 9 | def wrapped_f(*args): | ||
| 10 | if self.testcase in (oeRuntimeTest.testFailures or oeRuntimeTest.testErrors): | ||
| 11 | raise unittest.SkipTest("Testcase dependency not met: %s" % self.testcase) | ||
| 12 | f(*args) | ||
| 13 | wrapped_f.__name__ = f.__name__ | ||
| 14 | return wrapped_f | ||
| 15 | |||
| 16 | class skipIfSkipped(object): | ||
| 17 | |||
| 18 | def __init__(self,testcase): | ||
| 19 | self.testcase = testcase | ||
| 20 | |||
| 21 | def __call__(self,f): | ||
| 22 | def wrapped_f(*args): | ||
| 23 | if self.testcase in oeRuntimeTest.testSkipped: | ||
| 24 | raise unittest.SkipTest("Testcase dependency not met: %s" % self.testcase) | ||
| 25 | f(*args) | ||
| 26 | wrapped_f.__name__ = f.__name__ | ||
| 27 | return wrapped_f | ||
| 28 | |||
| 29 | class skipUnlessPassed(object): | ||
| 30 | |||
| 31 | def __init__(self,testcase): | ||
| 32 | self.testcase = testcase | ||
| 33 | |||
| 34 | def __call__(self,f): | ||
| 35 | def wrapped_f(*args): | ||
| 36 | if self.testcase in (oeRuntimeTest.testSkipped, oeRuntimeTest.testFailures, oeRuntimeTest.testErrors): | ||
| 37 | raise unittest.SkipTest("Testcase dependency not met: %s" % self.testcase) | ||
| 38 | f(*args) | ||
| 39 | wrapped_f.__name__ = f.__name__ | ||
| 40 | return wrapped_f | ||
