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.TestResultExternal(test)[source]

Result from a external test.

__bool__()[source]

This test returns the return value specified in the test initialisation.

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:
evaluate()[source]

Evaluate the test (do nothing in this case except building the TestResult).

Return type:

TestResultExternal