1ASSERTEQUALS(1) Local Manual ASSERTEQUALS(1)
2
4 assertEquals — an opinionated testing interface for Python
5
7 assertEquals [options] module
8
10 assertEquals 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, assertEquals
21 will use the curses(3) interface.
22 -f
23 --find-only assertEquals 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 assertEquals 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 assertEquals 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, assertEquals 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. assertEquals 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 -------------<| assertEquals |>-------------
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. assertEquals sets the PYTHONTESTING
73 environment variable to ‘assertEquals’ 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 assertEquals 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, assertEquals 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 assertEquals 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 assertEquals.
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 <ctrl>-L Refresh the list of available TestCases without run‐
105 ning them.
106
107 enter Run the selected tests and go to the detail screen if
108 there are non-passing tests.
109
110 left-arrow Alias for q.
111
112 q Exit assertEquals.
113
114 right-arrow Alias for enter.
115
116 space Alias for enter.
117
118 F5 Alias for enter.
119
120 Detail Screen
121 The detail screen shows a list of non-passing tests on the left side, and
122 the traceback for the currently selected test on the right. Failures are
123 displayed in red, and errors in yellow. Tests are listed in alphabetical
124 order.
125
126 F5 Run the tests again.
127
128 enter Open the traceback for the selected test in an error
129 screen.
130
131 left-arrow Alias for q.
132
133 q Exit back to the summary screen.
134
135 right-arrow Alias for enter.
136
137 space Alias for F5.
138
139 Error Screen
140 The error screen provides a primitive pager for viewing tracebacks.
141
142 left-arrow Alias for q.
143
144 q Exit back to the previous screen.
145
146 Debugging Screen
147 The debugging screen is a primitive terminal for interacting with a
148 Python debugger session. When a child process includes the string ‘(Pdb)
149 ’ in its output, assertEquals enters the debugging screen. When the
150 debugger exits, assertEquals returns to the previous screen, ignoring any
151 report output that may have followed the debugging session. You can eas‐
152 ily start debugging from any point in your program or tests by manually
153 setting a breakpoint:
154
155 import pdb; pdb.set_trace()
156
157 The Python debugger's command reference is online at:
158
159 http://docs.python.org/lib/debugger-commands.html
160
162 This program is known to work with the following software:
163
164 - FreeBSD 4.11
165 - Python 2.4.2
166
168 Run assertEquals's own tests, displaying a summary report on the standard
169 output:
170
171 $ assertEquals -s assertEquals.tests
172
174 python(1) curses(3)
175
177 assertEquals <trunk>
178
180 (c) 2005-2012 Chad Whitacre <http://www.zetadev.com/>
181 This program is beerware. If you like it, buy me a beer someday.
182 No warranty is expressed or implied.
183
184BSD January 1, 1970 BSD