2. Scripted Mode

If the --testcase option is not given, testosterone imports module, and then searches sys.modules for all modules at or below module that do not include any stopwords in their full dotted name. testosterone collects TestCase classes that are defined in these modules, and prints a summary report to the standard output of the format:

-------------------------------<| testosterone |>-------------------------------
<header row>
--------------------------------------------------------------------------------
<name>                                       <passing> <failures> <errors> <all>
--------------------------------------------------------------------------------
TOTALS                                       <passing> <failures> <errors> <all>

<name> is the full dotted name of a TestCase (this row is repeated for each TestCase). If the --find flag is set, then no tests are run, and <passing>, <failures>, and <errors> are each set to a single dash (-). Otherwise, <passing> is given as a percentage, with a terminating percent sign; the other three are given in absolute terms. There will always be at least one space between each field, and data rows will be longer than 80 characters iff the field values exceed the following character lengths:

field width
name 60
failures 4
errors 4
all 4

Note that in order for your TestCases to be found, you must import their containing modules within module. testosterone sets the PYTHONTESTING environment variable to testosterone so that you can avoid defining TestCases or importing testing modules in a production environment. You can also quarantine your tests in a subpackage, and give module as the dotted name of this subpackage.

If the --testcase flag is set, then only the named TestCase is run (any --find option is ignored), and testosterone delivers a detail report. This report is the usual output of unittest.TextTestRunner, preceded by the same first banner row as for the summary report.

For both summary and detail reports, testosterone guarantees that no program output will occur after the banner row.

testosterone is Zeta software. It is copyright © 2006 by Chad Whitacre, and is offered free of charge, warranty, and restrictions.