Imported Upstream version 1.2.1
[platform/upstream/python-nose.git] / nosetests.1
1 .TH nosetests 1 "2009-04-23" "0.11" "User Commands"
2 .SH NAME
3 nosetests \- nicer testing for python
4 .\" Man page generated from reStructeredText.
5 .INDENT 0.0
6 .UNINDENT
7
8 .SH SYNOPSIS
9 .INDENT 0.0
10 .INDENT 3.5
11 nosetests [options] [names]
12
13 .UNINDENT
14 .UNINDENT
15
16 .SH DESCRIPTION
17 nose collects tests automatically from python source files,
18 directories and packages found in its working directory (which
19 defaults to the current working directory). Any python source file,
20 directory or package that matches the testMatch regular expression
21 (by default: \fI(?:^|[b_.\-])[Tt]est)\fP will be collected as a test (or
22 source for collection of tests). In addition, all other packages
23 found in the working directory will be examined for python source files
24 or directories that match testMatch. Package discovery descends all
25 the way down the tree, so package.tests and package.sub.tests and
26 package.sub.sub2.tests will all be collected.
27
28 Within a test directory or package, any python source file matching
29 testMatch will be examined for test cases. Within a test module,
30 functions and classes whose names match testMatch and TestCase
31 subclasses with any name will be loaded and executed as tests. Tests
32 may use the assert keyword or raise AssertionErrors to indicate test
33 failure. TestCase subclasses may do the same or use the various
34 TestCase methods available.
35
36
37 .SS Selecting Tests
38 To specify which tests to run, pass test names on the command line:
39
40
41 .nf
42 nosetests only_test_this.py
43 .fi
44 Test names specified may be file or module names, and may optionally
45 indicate the test case to run by separating the module or file name
46 from the test case name with a colon. Filenames may be relative or
47 absolute. Examples:
48
49
50 .nf
51 nosetests test.module
52 nosetests another.test:TestCase.test_method
53 nosetests a.test:TestCase
54 nosetests /path/to/test/file.py:test_function
55 .fi
56 You may also change the working directory where nose looks for tests
57 by using the \-w switch:
58
59
60 .nf
61 nosetests \-w /path/to/tests
62 .fi
63 Note, however, that support for multiple \-w arguments is now deprecated
64 and will be removed in a future release. As of nose 0.10, you can get
65 the same behavior by specifying the target directories \fIwithout\fP
66 the \-w switch:
67
68
69 .nf
70 nosetests /path/to/tests /another/path/to/tests
71 .fi
72 Further customization of test selection and loading is possible
73 through the use of plugins.
74
75 Test result output is identical to that of unittest, except for
76 the additional features (error classes, and plugin\-supplied
77 features such as output capture and assert introspection) detailed
78 in the options below.
79
80
81 .SS Configuration
82 In addition to passing command\-line options, you may also put
83 configuration options in your project\'s \fIsetup.cfg\fP file, or a .noserc
84 or nose.cfg file in your home directory. In any of these standard
85 .ini\-style config files, you put your nosetests configuration in a
86 \fB[nosetests]\fP section. Options are the same as on the command line,
87 with the \-\- prefix removed. For options that are simple switches, you
88 must supply a value:
89
90
91 .nf
92 [nosetests]
93 verbosity=3
94 with\-doctest=1
95 .fi
96 All configuration files that are found will be loaded and their
97 options combined. You can override the standard config file loading
98 with the \fB\-c\fP option.
99
100
101 .SS Using Plugins
102 There are numerous nose plugins available via easy_install and
103 elsewhere. To use a plugin, just install it. The plugin will add
104 command line options to nosetests. To verify that the plugin is installed,
105 run:
106
107
108 .nf
109 nosetests \-\-plugins
110 .fi
111 You can add \-v or \-vv to that command to show more information
112 about each plugin.
113
114 If you are running nose.main() or nose.run() from a script, you
115 can specify a list of plugins to use by passing a list of plugins
116 with the plugins keyword argument.
117
118
119 .SS 0.9 plugins
120 nose 1.0 can use SOME plugins that were written for nose 0.9. The
121 default plugin manager inserts a compatibility wrapper around 0.9
122 plugins that adapts the changed plugin api calls. However, plugins
123 that access nose internals are likely to fail, especially if they
124 attempt to access test case or test suite classes. For example,
125 plugins that try to determine if a test passed to startTest is an
126 individual test or a suite will fail, partly because suites are no
127 longer passed to startTest and partly because it\'s likely that the
128 plugin is trying to find out if the test is an instance of a class
129 that no longer exists.
130
131
132 .SS 0.10 and 0.11 plugins
133 All plugins written for nose 0.10 and 0.11 should work with nose 1.0.
134
135
136 .SS Options
137
138 .TP
139 \fB\-V\fR\fR\fR, \fB\-\-version\fR\fR
140 Output nose version and exit
141
142
143 .TP
144 \fB\-p\fR\fR\fR, \fB\-\-plugins\fR\fR
145 Output list of available plugins and exit. Combine with higher verbosity for greater detail
146
147
148 .TP
149 \fB\-v\fR\fR=DEFAULT\fR, \fB\-\-verbose\fR\fR=DEFAULT
150 Be more verbose. [NOSE_VERBOSE]
151
152
153 .TP
154 \fB\-\-verbosity\fR\fR=VERBOSITY
155 Set verbosity; \-\-verbosity=2 is the same as \-v
156
157
158 .TP
159 \fB\-q\fR\fR=DEFAULT\fR, \fB\-\-quiet\fR\fR=DEFAULT
160 Be less verbose
161
162
163 .TP
164 \fB\-c\fR\fR=FILES\fR, \fB\-\-config\fR\fR=FILES
165 Load configuration from config file(s). May be specified multiple times; in that case, all config files will be loaded and combined
166
167
168 .TP
169 \fB\-w\fR\fR=WHERE\fR, \fB\-\-where\fR\fR=WHERE
170 Look for tests in this directory. May be specified multiple times. The first directory passed will be used as the working directory, in place of the current working directory, which is the default. Others will be added to the list of tests to execute. [NOSE_WHERE]
171
172
173 .TP
174 \fB\-\-py3where\fR\fR=PY3WHERE
175 Look for tests in this directory under Python 3.x. Functions the same as \'where\', but only applies if running under Python 3.x or above.  Note that, if present under 3.x, this option completely replaces any directories specified with \'where\', so the \'where\' option becomes ineffective. [NOSE_PY3WHERE]
176
177
178 .TP
179 \fB\-m\fR\fR=REGEX\fR, \fB\-\-match\fR\fR=REGEX\fR, \fB\-\-testmatch\fR\fR=REGEX
180 Files, directories, function names, and class names that match this regular expression are considered tests.  Default: (?:^|[b_./\-])[Tt]est [NOSE_TESTMATCH]
181
182
183 .TP
184 \fB\-\-tests\fR\fR=NAMES
185 Run these tests (comma\-separated list). This argument is useful mainly from configuration files; on the command line, just pass the tests to run as additional arguments with no switch.
186
187
188 .TP
189 \fB\-l\fR\fR=DEFAULT\fR, \fB\-\-debug\fR\fR=DEFAULT
190 Activate debug logging for one or more systems. Available debug loggers: nose, nose.importer, nose.inspector, nose.plugins, nose.result and nose.selector. Separate multiple names with a comma.
191
192
193 .TP
194 \fB\-\-debug\-log\fR\fR=FILE
195 Log debug messages to this file (default: sys.stderr)
196
197
198 .TP
199 \fB\-\-logging\-config\fR\fR=FILE\fR, \fB\-\-log\-config\fR\fR=FILE
200 Load logging config from this file \-\- bypasses all other logging config settings.
201
202
203 .TP
204 \fB\-I\fR\fR=REGEX\fR, \fB\-\-ignore\-files\fR\fR=REGEX
205 Completely ignore any file that matches this regular expression. Takes precedence over any other settings or plugins. Specifying this option will replace the default setting. Specify this option multiple times to add more regular expressions [NOSE_IGNORE_FILES]
206
207
208 .TP
209 \fB\-e\fR\fR=REGEX\fR, \fB\-\-exclude\fR\fR=REGEX
210 Don\'t run tests that match regular expression [NOSE_EXCLUDE]
211
212
213 .TP
214 \fB\-i\fR\fR=REGEX\fR, \fB\-\-include\fR\fR=REGEX
215 This regular expression will be applied to files, directories, function names, and class names for a chance to include additional tests that do not match TESTMATCH.  Specify this option multiple times to add more regular expressions [NOSE_INCLUDE]
216
217
218 .TP
219 \fB\-x\fR\fR\fR, \fB\-\-stop\fR\fR
220 Stop running tests after the first error or failure
221
222
223 .TP
224 \fB\-P\fR\fR\fR, \fB\-\-no\-path\-adjustment\fR\fR
225 Don\'t make any changes to sys.path when loading tests [NOSE_NOPATH]
226
227
228 .TP
229 \fB\-\-exe\fR\fR
230 Look for tests in python modules that are executable. Normal behavior is to exclude executable modules, since they may not be import\-safe [NOSE_INCLUDE_EXE]
231
232
233 .TP
234 \fB\-\-noexe\fR\fR
235 DO NOT look for tests in python modules that are executable. (The default on the windows platform is to do so.)
236
237
238 .TP
239 \fB\-\-traverse\-namespace\fR\fR
240 Traverse through all path entries of a namespace package
241
242
243 .TP
244 \fB\-\-first\-package\-wins\fR\fR\fR, \fB\-\-first\-pkg\-wins\fR\fR\fR, \fB\-\-1st\-pkg\-wins\fR\fR
245 nose\'s importer will normally evict a package from sys.modules if it sees a package with the same name in a different location. Set this option to disable that behavior.
246
247
248 .TP
249 \fB\-a\fR\fR=ATTR\fR, \fB\-\-attr\fR\fR=ATTR
250 Run only tests that have attributes specified by ATTR [NOSE_ATTR]
251
252
253 .TP
254 \fB\-A\fR\fR=EXPR\fR, \fB\-\-eval\-attr\fR\fR=EXPR
255 Run only tests for whose attributes the Python expression EXPR evaluates to True [NOSE_EVAL_ATTR]
256
257
258 .TP
259 \fB\-s\fR\fR\fR, \fB\-\-nocapture\fR\fR
260 Don\'t capture stdout (any stdout output will be printed immediately) [NOSE_NOCAPTURE]
261
262
263 .TP
264 \fB\-\-nologcapture\fR\fR
265 Disable logging capture plugin. Logging configurtion will be left intact. [NOSE_NOLOGCAPTURE]
266
267
268 .TP
269 \fB\-\-logging\-format\fR\fR=FORMAT
270 Specify custom format to print statements. Uses the same format as used by standard logging handlers. [NOSE_LOGFORMAT]
271
272
273 .TP
274 \fB\-\-logging\-datefmt\fR\fR=FORMAT
275 Specify custom date/time format to print statements. Uses the same format as used by standard logging handlers. [NOSE_LOGDATEFMT]
276
277
278 .TP
279 \fB\-\-logging\-filter\fR\fR=FILTER
280 Specify which statements to filter in/out. By default, everything is captured. If the output is too verbose,
281 use this option to filter out needless output.
282 Example: filter=foo will capture statements issued ONLY to
283  foo or foo.what.ever.sub but not foobar or other logger.
284 Specify multiple loggers with comma: filter=foo,bar,baz.
285 If any logger name is prefixed with a minus, eg filter=\-foo,
286 it will be excluded rather than included. Default: exclude logging messages from nose itself (\-nose). [NOSE_LOGFILTER]
287
288
289 .TP
290 \fB\-\-logging\-clear\-handlers\fR\fR
291 Clear all other logging handlers
292
293
294 .TP
295 \fB\-\-with\-coverage\fR\fR
296 Enable plugin Coverage: 
297 Activate a coverage report using Ned Batchelder\'s coverage module.
298  [NOSE_WITH_COVERAGE]
299
300
301 .TP
302 \fB\-\-cover\-package\fR\fR=PACKAGE
303 Restrict coverage output to selected packages [NOSE_COVER_PACKAGE]
304
305
306 .TP
307 \fB\-\-cover\-erase\fR\fR
308 Erase previously collected coverage statistics before run
309
310
311 .TP
312 \fB\-\-cover\-tests\fR\fR
313 Include test modules in coverage report [NOSE_COVER_TESTS]
314
315
316 .TP
317 \fB\-\-cover\-inclusive\fR\fR
318 Include all python files under working directory in coverage report.  Useful for discovering holes in test coverage if not all files are imported by the test suite. [NOSE_COVER_INCLUSIVE]
319
320
321 .TP
322 \fB\-\-cover\-html\fR\fR
323 Produce HTML coverage information
324
325
326 .TP
327 \fB\-\-cover\-html\-dir\fR\fR=DIR
328 Produce HTML coverage information in dir
329
330
331 .TP
332 \fB\-\-cover\-branches\fR\fR
333 Include branch coverage in coverage report [NOSE_COVER_BRANCHES]
334
335
336 .TP
337 \fB\-\-cover\-xml\fR\fR
338 Produce XML coverage information
339
340
341 .TP
342 \fB\-\-cover\-xml\-file\fR\fR=FILE
343 Produce XML coverage information in file
344
345
346 .TP
347 \fB\-\-pdb\fR\fR
348 Drop into debugger on errors
349
350
351 .TP
352 \fB\-\-pdb\-failures\fR\fR
353 Drop into debugger on failures
354
355
356 .TP
357 \fB\-\-no\-deprecated\fR\fR
358 Disable special handling of DeprecatedTest exceptions.
359
360
361 .TP
362 \fB\-\-with\-doctest\fR\fR
363 Enable plugin Doctest: 
364 Activate doctest plugin to find and run doctests in non\-test modules.
365  [NOSE_WITH_DOCTEST]
366
367
368 .TP
369 \fB\-\-doctest\-tests\fR\fR
370 Also look for doctests in test modules. Note that classes, methods and functions should have either doctests or non\-doctest tests, not both. [NOSE_DOCTEST_TESTS]
371
372
373 .TP
374 \fB\-\-doctest\-extension\fR\fR=EXT
375 Also look for doctests in files with this extension [NOSE_DOCTEST_EXTENSION]
376
377
378 .TP
379 \fB\-\-doctest\-result\-variable\fR\fR=VAR
380 Change the variable name set to the result of the last interpreter command from the default \'_\'. Can be used to avoid conflicts with the _() function used for text translation. [NOSE_DOCTEST_RESULT_VAR]
381
382
383 .TP
384 \fB\-\-doctest\-fixtures\fR\fR=SUFFIX
385 Find fixtures for a doctest file in module with this name appended to the base name of the doctest file
386
387
388 .TP
389 \fB\-\-with\-isolation\fR\fR
390 Enable plugin IsolationPlugin: 
391 Activate the isolation plugin to isolate changes to external
392 modules to a single test module or package. The isolation plugin
393 resets the contents of sys.modules after each test module or
394 package runs to its state before the test. PLEASE NOTE that this
395 plugin should not be used with the coverage plugin, or in any other case
396 where module reloading may produce undesirable side\-effects.
397  [NOSE_WITH_ISOLATION]
398
399
400 .TP
401 \fB\-d\fR\fR\fR, \fB\-\-detailed\-errors\fR\fR\fR, \fB\-\-failure\-detail\fR\fR
402 Add detail to error output by attempting to evaluate failed asserts [NOSE_DETAILED_ERRORS]
403
404
405 .TP
406 \fB\-\-with\-profile\fR\fR
407 Enable plugin Profile: 
408 Use this plugin to run tests using the hotshot profiler. 
409  [NOSE_WITH_PROFILE]
410
411
412 .TP
413 \fB\-\-profile\-sort\fR\fR=SORT
414 Set sort order for profiler output
415
416
417 .TP
418 \fB\-\-profile\-stats\-file\fR\fR=FILE
419 Profiler stats file; default is a new temp file on each run
420
421
422 .TP
423 \fB\-\-profile\-restrict\fR\fR=RESTRICT
424 Restrict profiler output. See help for pstats.Stats for details
425
426
427 .TP
428 \fB\-\-no\-skip\fR\fR
429 Disable special handling of SkipTest exceptions.
430
431
432 .TP
433 \fB\-\-with\-id\fR\fR
434 Enable plugin TestId: 
435 Activate to add a test id (like #1) to each test name output. Activate
436 with \-\-failed to rerun failing tests only.
437  [NOSE_WITH_ID]
438
439
440 .TP
441 \fB\-\-id\-file\fR\fR=FILE
442 Store test ids found in test runs in this file. Default is the file .noseids in the working directory.
443
444
445 .TP
446 \fB\-\-failed\fR\fR
447 Run the tests that failed in the last test run.
448
449
450 .TP
451 \fB\-\-processes\fR\fR=NUM
452 Spread test run among this many processes. Set a number equal to the number of processors or cores in your machine for best results. [NOSE_PROCESSES]
453
454
455 .TP
456 \fB\-\-process\-timeout\fR\fR=SECONDS
457 Set timeout for return of results from each test runner process. [NOSE_PROCESS_TIMEOUT]
458
459
460 .TP
461 \fB\-\-process\-restartworker\fR\fR
462 If set, will restart each worker process once their tests are done, this helps control memory leaks from killing the system. [NOSE_PROCESS_RESTARTWORKER]
463
464
465 .TP
466 \fB\-\-with\-xunit\fR\fR
467 Enable plugin Xunit: This plugin provides test results in the standard XUnit XML format. [NOSE_WITH_XUNIT]
468
469
470 .TP
471 \fB\-\-xunit\-file\fR\fR=FILE
472 Path to xml file to store the xunit report in. Default is nosetests.xml in the working directory [NOSE_XUNIT_FILE]
473
474
475 .TP
476 \fB\-\-all\-modules\fR\fR
477 Enable plugin AllModules: Collect tests from all python modules.
478  [NOSE_ALL_MODULES]
479
480
481 .TP
482 \fB\-\-collect\-only\fR\fR
483 Enable collect\-only: 
484 Collect and output test names only, don\'t run any tests.
485  [COLLECT_ONLY]
486
487
488 .SH AUTHOR
489 jpellerin+nose@gmail.com
490
491 .SH COPYRIGHT
492 LGPL
493
494 .\" Generated by docutils manpage writer on 2012-09-03 09:06.
495 .\"