lisa.tests.base.ResultBundle#
- class lisa.tests.base.ResultBundle(result, utc_datetime=None, context=None)[source]#
Bases:
ResultBundleBaseBundle for storing test results
- Parameters:
result (
Result) – Indicates whether the associated test passed. It will also be used as the truth-value of a ResultBundle.utc_datetime (datetime.datetime) – UTC time at which the result was collected, or
Noneto record the current datetime.context (dict(str, object)) – Contextual information to attach to the bundle. Keep the content small, as size of
ResultBundleinstances matters a lot for storing long test sessions results.
TestMetriccan be added to an instance of this class. This can make it easier for users of your tests to understand why a certain test passed or failed. For instance:def test_is_noon(): now = time.localtime().tm_hour res = ResultBundle(Result.PASSED if now == 12 else Result.FAILED) res.add_metric("current time", now) return res >>> res_bundle = test_is_noon() >>> print(res_bundle.result.name) FAILED # At this point, the user can wonder why the test failed. # Metrics are here to help, and are printed along with the result: >>> print(res_bundle) FAILED: current time=11
Methods
Alternate constructor where
ResultBundle.resultis determined from a bool.Raise an
ResultBundlewith theResult.SKIPPEDresult, thereby short-circuiting the rest of the test.__bool__()inheritedTrueif theresultisResult.PASSED,Falseotherwise.add_metric()inheritedLets you append several test
TestMetricto the bundle.display_and_exit()inheritedpretty_format()inherited
Methods#
- classmethod ResultBundle.from_bool(cond, *args, **kwargs)[source]#
Alternate constructor where
ResultBundle.resultis determined from a bool
- classmethod ResultBundle.raise_skip(msg, from_=None, **kwargs)[source]#
Raise an
ResultBundlewith theResult.SKIPPEDresult, thereby short-circuiting the rest of the test.- Parameters:
This is typically used as a way to bail out while indicating to the user that the test has essentially been skipped because the target does not support what the test is testing.
- ResultBundle.__bool__()#
Inherited method, see
lisa.tests.base.ResultBundleBase.__bool__()Trueif theresultisResult.PASSED,Falseotherwise.
- ResultBundle.add_metric(name, data, units=None)#
Inherited method, see
lisa.tests.base.ResultBundleBase.add_metric()Lets you append several test
TestMetricto the bundle.
- ResultBundle.display_and_exit() None#
Inherited method, see
lisa.tests.base.ResultBundleBase.display_and_exit()
- ResultBundle.pretty_format(multiline=True)#
Inherited method, see
lisa.tests.base.ResultBundleBase.pretty_format()