mirror of
git://git.yoctoproject.org/poky
synced 2026-09-03 08:58:15 +00:00
Decorators should return whatever the decorated methods return. (From OE-Core rev: c92513d6ff3f8f06d937a5cdf4d94708f27c3850) Signed-off-by: Mihai Lindner <mihaix.lindner@linux.intel.com> Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
# Copyright (C) 2013 Intel Corporation
|
|
#
|
|
# Released under the MIT license (see COPYING.MIT)
|
|
|
|
# Some custom decorators that can be used by unittests
|
|
# Most useful is skipUnlessPassed which can be used for
|
|
# creating dependecies between two test methods.
|
|
|
|
from oeqa.oetest import *
|
|
|
|
class skipIfFailure(object):
|
|
|
|
def __init__(self,testcase):
|
|
self.testcase = testcase
|
|
|
|
def __call__(self,f):
|
|
def wrapped_f(*args):
|
|
if self.testcase in (oeRuntimeTest.testFailures or oeRuntimeTest.testErrors):
|
|
raise unittest.SkipTest("Testcase dependency not met: %s" % self.testcase)
|
|
return f(*args)
|
|
wrapped_f.__name__ = f.__name__
|
|
return wrapped_f
|
|
|
|
class skipIfSkipped(object):
|
|
|
|
def __init__(self,testcase):
|
|
self.testcase = testcase
|
|
|
|
def __call__(self,f):
|
|
def wrapped_f(*args):
|
|
if self.testcase in oeRuntimeTest.testSkipped:
|
|
raise unittest.SkipTest("Testcase dependency not met: %s" % self.testcase)
|
|
return f(*args)
|
|
wrapped_f.__name__ = f.__name__
|
|
return wrapped_f
|
|
|
|
class skipUnlessPassed(object):
|
|
|
|
def __init__(self,testcase):
|
|
self.testcase = testcase
|
|
|
|
def __call__(self,f):
|
|
def wrapped_f(*args):
|
|
if self.testcase in oeRuntimeTest.testSkipped or \
|
|
self.testcase in oeRuntimeTest.testFailures or \
|
|
self.testcase in oeRuntimeTest.testErrors:
|
|
raise unittest.SkipTest("Testcase dependency not met: %s" % self.testcase)
|
|
return f(*args)
|
|
wrapped_f.__name__ = f.__name__
|
|
return wrapped_f
|