1TESTOSTERONE(1) Local Manual TESTOSTERONE(1)
2
4 testosterone — a manly testing interface for Python
5
7 testosterone [options] module
8
10 testosterone is an interface for running tests written with the Python
11 standard library's unittest module. It delivers summary and detail
12 reports on TestCases discovered in module-space, via both a command-line
13 and a curses(3) interface. The interactive mode is the default, but it
14 depends on the non-interactive mode. For debugging, static tracebacks and
15 interactive Python debugger (Pdb) sessions are available in both scripted
16 and interactive modes.
17
19 -s
20 --scripted Use the command-line interface. If not set, testosterone
21 will use the curses(3) interface.
22 -f
23 --find-only testosterone should find TestCases but not run them. This
24 only obtains in scripted mode, for summary reports.
25 -x stopwords
26 --stopwords stopwords
27 stopwords is a comma-delimited list of strings that, if
28 they appear in a module's full dotted name, will prevent
29 that module from being included in the search for Test‐
30 Cases.
31 -t testcase
32 --testcase testcase
33 --TestCase testcase
34 testosterone should only run the tests found in testcase,
35 which is the name of a Python unittest.TestCase class
36 within the module specified by module. Given this option,
37 testosterone will output a detail report for the named
38 TestCase; without it, a summary report for all TestCases
39 found at or below module. This option only obtains in
40 scripted mode.
41
43 If the --testcase option is not given, testosterone imports module, and
44 then searches sys.modules for all modules at or below module that do not
45 include any stopwords in their full dotted name. testosterone collects
46 TestCase classes that are defined in these modules, and prints a summary
47 report to the standard output of the format (actually 80 chars wide):
48
49 -------------<| testosterone |>-------------
50 <header row>
51 --------------------------------------------
52 <name> <passing> <failures> <errors> <all>
53 --------------------------------------------
54 TOTALS <passing> <failures> <errors> <all>
55
56 <name> is the full dotted name of a TestCase (this row is repeated for
57 each TestCase). If the --find flag is set, then no tests are run, and
58 <passing>, <failures>, and <errors> are each set to a single dash (‘-’).
59 Otherwise, <passing> is given as a percentage, with a terminating percent
60 sign; the other three are given in absolute terms. There will always be
61 at least one space between each field, and data rows will be longer than
62 80 characters iff the field values exceed the following character
63 lengths:
64
65 field width
66 name 60
67 failures 4
68 errors 4
69 total 4
70
71 Note that in order for your TestCases to be found, you must import their
72 containing modules within module. testosterone sets the PYTHONTESTING
73 environment variable to ‘testosterone’ so that you can avoid defining
74 TestCases or importing testing modules in a production environment. You
75 can also quarantine your tests in a subpackage, and give module as the
76 dotted name of this subpackage. If the --testcase flag is set, then only
77 the named TestCase is run (any --find option is ignored), and
78 testosterone delivers a detail report. This report is the usual output of
79 unittest.TextTestRunner, preceded by the same first banner row as for the
80 summary report. For both summary and detail reports, testosterone guar‐
81 antees that no program output will occur after the banner row.
82
84 Interactive mode is a front end for scripted mode. There are two main
85 screens, representing the summary and detail reports described above.
86 Each is populated by calling testosterone in scripted mode in a child
87 process, and then parsing and formatting the output. There are two addi‐
88 tional screens: One is a primitive pager showing a Python traceback,
89 which is used both for viewing individual test failures, as well as for
90 error handling in both parent and child processes. The other is a primi‐
91 tive terminal for interacting with a Pdb session in a child process. You
92 can send a SIGINT (<ctrl>-C) at any time to exit testosterone.
93
94 Summary Screen
95 The summary screen shows the summary report as described above, but item
96 names are indented rather than given in full. Modules are shown in gray,
97 and un-run TestCases in white. TestCases with non-passing tests are shown
98 in red, and those that pass in green. You may run any subset of the pre‐
99 sented tests. The totals for the most recent test run are shown at the
100 bottom of the screen, in green if all tests pass, red otherwise. Test‐
101 Cases for which there are results but that were not part of the most
102 recent test run are shown in faded red and green.
103
104 F5 Refresh the list of available TestCases without running
105 them.
106
107 enter Run the selected tests and go to the detail screen if there
108 are non-passing tests.
109
110 q Exit testosterone.
111
112 right-arrow Alias for enter
113
114 space Run the selected tests and stay on the summary screen.
115
116 Detail Screen
117 The detail screen shows a list of non-passing tests on the left side, and
118 the traceback for the currently selected test on the right. Failures are
119 displayed in red, and errors in yellow. Tests are listed in alphabetical
120 order.
121
122 F5 Run the tests again.
123
124 enter Open the traceback for the selected test in an error
125 screen.
126
127 left-arrow Alias for q.
128
129 q Exit back to the summary screen.
130
131 right-arrow Alias for enter.
132
133 space Alias for F5.
134
135 Error Screen
136 The error screen provides a primitive pager for viewing tracebacks.
137
138 left-arrow Alias for q.
139
140 q Exit back to the previous screen.
141
142 Debugging Screen
143 The debugging screen is a primitive terminal for interacting with a
144 Python debugger session. When a child process includes the string ‘(Pdb)
145 ’ in its output, testosterone enters the debugging screen. When the
146 debugger exits, testosterone returns to the previous screen, ignoring any
147 report output that may have followed the debugging session. You can eas‐
148 ily start debugging from any point in your program or tests by manually
149 setting a breakpoint:
150
151 import pdb; pdb.set_trace()
152
153 The Python debugger's command reference is online at:
154
155 http://docs.python.org/lib/debugger-commands.html
156
158 This program is known to work with the following software:
159
160 - FreeBSD 4.11
161 - Python 2.4.2
162
164 Run testosterone's own tests, displaying a summary report on the standard
165 output:
166
167 $ testosterone -s testosterone.tests
168
170 python(1) curses(3)
171
173 testosterone 0.4.1
174
176 (c) 2005 Chad Whitacre <http://www.zetadev.com/>
177 This program is beerware. If you like it, buy me a beer someday.
178 No warranty is expressed or implied.
179
180BSD February 22, 2006 BSD