test_external
– Class to import external test
External test used to represent user formatted results in the report.
This test has been designed in order to offer the possibility to define and run user-defined tests outside valjean and include their results in a report, along with the native valjean tests.
The user is responsible for defining and representing the test results. The
representation must be done with templates (see templates
module).
For example, the simplest case is a custom plot to represent a test. In that
case, if the path to the image is known a TextTemplate
can
be created and given to the test:
>>> txtemp = TextTemplate("And this represents Javert\n\n"
... ".. image:: ../../doc/src/images/javert.jpg\n\n")
>>> textr = TestExternal(txtemp, name='', success=True).evaluate()
>>> print(bool(textr))
True
- class valjean.javert.test_external.TestExternal(*templates, name, description='', labels=None, success=True)[source]
Class building a test that will return the boolean value specified at initialisation.
- __init__(*templates, name, description='', labels=None, success=True)[source]
Initialize the
TestExternal
object with the templates to represent in the report, a name, a description of the test (may be long).External test are performed by the user who only gives its representation as templates and its return value. The return value can be an arbitrary value (a test that always returns True or False) for example.
- Parameters:
templates (TextTemplate, PlotTemplate, TableTemplate) – templates representing the external test
name (str) – name of the test
description (str) – description of the test expected with context
labels (dict) – labels for test classification
success (bool) – returned value by
TestResultExternal