dectest.suite

The main test suite class, TestSuite is found in this module.

class dectest.suite.TestSuite(name, config=None, logger=None)[source]

This is the main test suite class. It should be asigned to a variable at import time, and can then be used to reference decorators that can be used for detailing any tests created.

test()[source]

Runs all the test cases.

register(name, method=False)[source]

Creates a new test case, with the given name. The TestCase object will be availible as an attribute of the TestSuite with the same name as the new test case.

>>> ts = TestSuite()
>>> @ts.register("tc")
... def test():
...     return
...
>>> ts.tc
<dectest.suite.TestCase instance at 0xb71fcc2c>

Warning

If the decorated object is a method of a class, then the method argument must be true. This is because dectest cannot obtain a copy of an instance of the class untill runtime, so we need to know if to catch the self variable.

class dectest.suite.TestCase(config, logger, activated_sideaffects, method, name)

An invididual test case, containing all the information it needs to be tested. This class should not be created manually, as instances will be automatically created and made accessible from the TestSuite class.

Side affect tests can be used from this class. For example, the GlobalStateChange side affect test can be activated as show below:

ts = TestSuite(__name__)

@ts.register('a')
@ts.a.globalstatechange({})
def foo():
    reuturn

print ts.a.__class__
# dectest.suite.TestCase
input(*args, **kwargs)

Sets the input to the function in the test case. This is a decorator.

out(output=None)

Sets the expected/predicted output of the function in the test case. This is a decorator.

Previous topic

dectest

Next topic

dectest.sideaffects

This Page