services.api

API definitions for CleverSheep test services.

Module Members

Classes

class services.api.Reporter

Support for test execution reporting.

This is responsible for reporting test progress to the user. There can be more than one concrete subclass. The cs-test framework comes with built-in subclasses for output to a simple terminal, the test.log file and a curses based UI.

digraph foo {
rankdir=BT;
ranksep=0.3;
node[fontsize=10 margin=0.01 height=0.2 width=0.4];
edge[arrowsize=0.6 arrowhead=onormal];
"cstest.services.api.Reporter" [color=blue height=0.4 width=0.6];
    "cstest.ui.terminal.Terminal" -> "cstest.services.api.Reporter";
}

Subclass: Terminal

addstr(text, style=None)

Add text with a given style to the output.

This is used to produce coloured and emphasised output on terminals that support it. The style names are define in the colours module.

The style argument may be ignored by implementations.

endTest(suite, test, status)

Invoked when a test has completed without any errors.

This is invoked before leaveTest().

Arguments

suite, test
The test just executed and its parent suite.
status
A Status instance. Its value will typically be ‘PASS’ and it will not carry any run-time exception information.
enterSuite(suite, test)

Invoked when a suite is about to be ‘entered’.

This is invoked when a test is about to be run and no previous test has been executed or the previous test is in a different suite. Since suites may be nested, this may be invoked more than one before the test is invoked.

Arguments

suite, test
The suite being entered and the test that is going to be run. The test is not necessarily an immediate member of the suite; the suite may be the test’s grandparent, great-grandparent suite, etc.
enterTest(suite, test)

Invoked to indicate that ‘test-mode’ is being entered.

This is invoked immediately before the test method is invoked. Typical uses for this are to adjust the indentation level for future output and to announce that the test is starting.

Arguments

suite, test
The test being executed and its parent suite.
leaveSuite(suite, test)

Invoked when a suite has been ‘left’.

This is pretty much the inverse of enterSuite(). Calls to this are triggered when the next test to executed is in a differetn suite or no further tests are left.

Arguments

suite, test
The suite that has been left and an ‘associated’ test. The test parameter is probably not os much use. It exists primarily to make the signature match enterSuite(), enterTest(), etc. Normall the test is the next test that will be executed, but when not test remain to be executed it will be the last test that was invoked.
leaveTest(suite, test)

Invoked to indicate that ‘test-mode’ has been left.

This is invoked after the test’s result and any errors have beeb reported.

Arguments

suite, test
The test just executed and its parent suite.
reportFixtureFailure(suite, test, problemReport)

Invoked when a fixture function terminated with an error.

This is invoked when any setUp, tearDown, suiteSetUp or suiteTearDown method raises any unhandled exception.

Arguments

suite, test
The test just executed and its parent suite.
problemReport
TODO.
reportTestFailure(suite, test, problemReport)

Invoked when a test has terminated with an error.

This is invoked before leaveTest().

Arguments

suite, test
The test just executed and its parent suite.
problemReport
TODO.
startRun()

Invoked when a test run is about to start.

A typical use of this is to write the date and time to the log file.