lisa.tests.base.TestBundleMeta#
- class lisa.tests.base.TestBundleMeta(cls_name, bases, dct, **kwargs)[source]#
Bases:
ABCMetaMetaclass of
TestBundleBase.Method with a return annotation of
ResultBundleBaseare wrapped to:Update the
contextattribute of a returnedResultBundleBaseAdd an
undecided_filterattribute, withadd_undecided_filter()decorator, so that any test method can be used as a pre-filter for another one right away.Wrap
_from_targetto provide a singlecollectorparameter, built from the composition of the collectors provided by_make_collectormethods in the base class tree.
If
_from_targetis defined in the class butfrom_targetis not, a stub is created and the annotation of_from_targetis copied to the stub. The annotation is then removed from_from_targetso that it is not picked up by exekall.The signature of
from_targetis the result of merging the originalcls.from_targetparameters with the ones defined in_from_target.Methods
Turn any method returning a
ResultBundleBaseinto a decorator that can be used as a test method filter.Decorator to intercept returned
ResultBundleand attach some contextual information.
Methods#
- static TestBundleMeta.add_undecided_filter(func)[source]#
Turn any method returning a
ResultBundleBaseinto a decorator that can be used as a test method filter.The filter decorator is accessible as the
undecided_filterattribute of the decorated method.Once a test is decorated, the filter method will be run in addition to the wrapped test, and if the filter does not succeed, the
ResultBundleBaseresult will be set toResult.UNDECIDED.- Example:
class Foo(TestBundle): @TestBundle.add_undecided_filter def test_foo(self, xxx=42, ...): ... # Alternatively, ResultBundle return annotation will # automatically decorate the method with TestBundleMeta # metaclass. def test_foo(self, xxx=42, ...) -> ResultBundle: ... class Bar(Foo): # Set xxx=55 as default, but this can be overriden when # test_bar() is called. @Foo.test_foo.undecided_filter(xxx=77) def test_bar(self, yyy=43, ...) -> ResultBundle: ...
The resulting decorated method can take the union of keyword parameters:
bar = Bar() bar.test_bar(xxx=33, yyy=55) # Same as bar.test_bar(33, yyy=55) # But this fails, since only keyword arguments can be passed to the # wrapping pre-test bar.test_bar(33, 55)
If there is a parameter conflict, it is detected at import time and will result in a
TypeError.Note
Even if the pre-test does not succeed, the wrapped test is still executed, so that the ResultBundle metrics are updated and the artifacts still produced. This can be important in order to manually analyse results in case the pre-filter was overly conservative and marked a usable result as UNDECIDED.
- classmethod TestBundleMeta.test_method(func)[source]#
Decorator to intercept returned
ResultBundleand attach some contextual information.