1NOSETESTS(1) User Commands NOSETESTS(1)
2
3
4
6 nosetests - unit testing for Python software
7
9 nosetests [options] [names]
10
12 nose provides extended test discovery and running features for
13 unittest.
14
15 nose collects tests automatically from python source files, directories
16 and packages found in its working directory (which defaults to the cur‐
17 rent working directory). Any python source file, directory or package
18 that matches the testMatch regular expression (by default:
19 (?:^|[\b_\.-])[Tt]est) will be collected as a test (or source for col‐
20 lection of tests). In addition, all other packages found in the working
21 directory will be examined for python source files or directories that
22 match testMatch. Package discovery descends all the way down the tree,
23 so package.tests and package.sub.tests and package.sub.sub2.tests will
24 all be collected.
25
26 Within a test directory or package, any python source file matching
27 testMatch will be examined for test cases. Within a test module, func‐
28 tions and classes whose names match testMatch and TestCase subclasses
29 with any name will be loaded and executed as tests. Tests may use the
30 assert keyword or raise AssertionErrors to indicate test failure. Test‐
31 Case subclasses may do the same or use the various TestCase methods
32 available.
33
34 Selecting Tests
35
36 To specify which tests to run, pass test names on the command line:
37
38 nosetests only_test_this.py
39
40 Test names specified may be file or module names, and may optionally
41 indicate the test case to run by separating the module or file name
42 from the test case name with a colon. Filenames may be relative or
43 absolute. Examples:
44
45 nosetests test.module
46 nosetests another.test:TestCase.test_method
47 nosetests a.test:TestCase
48 nosetests /path/to/test/file.py:test_function
49
50 You may also change the working directory where nose looks for tests,
51 use the -w switch:
52
53 nosetests -w /path/to/tests
54
55
56 Note however that support for multiple -w arguments is deprecated in
57 this version and will be removed in a future release, since as of nose
58 0.10 you can get the same behavior by specifying the target directories
59 *without* the -w switch:
60
61 nosetests /path/to/tests /another/path/to/tests
62
63 Further customization of test selection and loading is possible through
64 the use of plugins.
65
66 Test result output is identical to that of unittest, except for the
67 additional features (error classes, and plugin-supplied features such
68 as output capture and assert introspection) detailed in the options
69 below.
70
71 Configuration
72
73 In addition to passing command-line options, you may also put configu‐
74 ration options in a .noserc or nose.cfg file in your home directory.
75 These are standard .ini-style config files. Put your nosetests configu‐
76 ration in a [nosetests] section, with the -- prefix removed:
77
78 [nosetests]
79 verbosity=3
80 with-doctest=1
81
82 All configuration files that are found will be loaded and their options
83 combined.
84
85 options:
86 -h, --help
87 show this help message and exit
88
89 -V, --version
90 Output nose version and exit
91
92 -p, --plugins
93 Output list of available plugins and exit. Combine with higher
94 verbosity for greater detail
95
96 -v, --verbose
97 Be more verbose. [NOSE_VERBOSE]
98
99 --verbosity=VERBOSITY
100 Set verbosity; --verbosity=2 is the same as -v
101
102 -q, --quiet
103
104 -c FILES, --config=FILES
105 Load configuration from config file(s). May be specified multi‐
106 ple times; in that case, all config files will be loaded and
107 combined
108
109 -w WHERE, --where=WHERE
110 Look for tests in this directory. May be specified multiple
111 times. The first directory passed will be used as the working
112 directory, in place of the current working directory, which is
113 the default. Others will be added to the list of tests to exe‐
114 cute. [NOSE_WHERE]
115
116 -m TESTMATCH, --match=TESTMATCH, --testmatch=TESTMATCH
117 Use this regular expression to find tests [NOSE_TESTMATCH]
118
119 --tests=TESTNAMES
120 Run these tests (comma-separated list). This argument is useful
121 mainly from configuration files; on the command line, just pass
122 the tests to run as additional arguments with no switch.
123
124 -l DEBUG, --debug=DEBUG
125 Activate debug logging for one or more systems. Available debug
126 loggers: nose, nose.importer, nose.inspector, nose.plugins,
127 nose.result and nose.selector. Separate multiple names with a
128 comma.
129
130 --debug-log=DEBUGLOG
131 Log debug messages to this file (default: sys.stderr)
132
133 --logging-config=LOGGINGCONFIG, --log-config=LOGGINGCONFIG
134 Load logging config from this file -- bypasses all other logging
135 config settings.
136
137 -e EXCLUDE, --exclude=EXCLUDE
138 Don't run tests that match regular expression [NOSE_EXCLUDE]
139
140 -i INCLUDE, --include=INCLUDE
141 Also run tests that match regular expression [NOSE_INCLUDE]
142
143 -x, --stop
144 Stop running tests after the first error or failure
145
146 -P, --no-path-adjustment
147 Don't make any changes to sys.path when loading tests
148 [NOSE_NOPATH]
149
150 --exe Look for tests in python modules that are executable. Normal
151 behavior is to exclude executable modules, since they may not be
152 import-safe [NOSE_INCLUDE_EXE]
153
154 --noexe
155 DO NOT look for tests in python modules that are executable.
156 (The default on the windows platform is to do so.)
157
158 --with-html-output
159 Enable plugin HtmlOutput: Output test results as ugly, unstyled
160 html. [NOSE_WITH_HTML-OUTPUT]
161
162 --with-watch
163 Enable plugin NoseWatch: watch failing tests, retesting when
164 modified [NOSE_WITH_WATCH]
165
166 --with-stopwatch
167 Enable plugin Stopwatch: (no help available) [NOSE_WITH_STOP‐
168 WATCH]
169
170 --faster-than=FASTER_THAN
171 Run only tests that are faster than FASTER_THAN seconds.
172
173 --stopwatch-file=STOPWATCH_FILE
174 Store test timing results in this file.
175
176 --with-figleafsections
177 Enable plugin FigleafSections: (no help available)
178 [NOSE_WITH_FIGLEAFSECTIONS]
179
180 --figleaf-file=FIGLEAF_FILE
181 Store figleaf section coverage in this file
182
183 --decorator-file=DECORATOR_FILE
184 Apply attributes in this file to matching functions, classes,
185 and methods
186
187 --with-tty
188 Enable plugin NoseTTY: run nosetests more interactively
189 [NOSE_WITH_TTY]
190
191 --tty Enable plugin NoseTTY: run nosetests more interactively
192 [NOSE_TTY]
193
194 --tty-editor=NOSE_TTY_EDITOR
195 editor program [NOSE_TTY_EDITOR or EDITOR] (currently: `None`)
196
197 --tty-edit-cmd=NOSE_TTY_EDIT_CMD
198 template to invoke edit command. [NOSE_TTY_EDIT_CMD] (cur‐
199 rently: `%(editor)s %(filename)s --line %(lineno)s`)
200
201 -a ATTR, --attr=ATTR
202 Run only tests that have attributes specified by ATTR
203 [NOSE_ATTR]
204
205 -A EXPR, --eval-attr=EXPR
206 Run only tests for whose attributes the Python expression EXPR
207 evaluates to True [NOSE_EVAL_ATTR]
208
209 -s, --nocapture
210 Don't capture stdout (any stdout output will be printed immedi‐
211 ately) [NOSE_NOCAPTURE]
212
213 --with-coverage
214 Enable plugin Coverage: If you have Ned Batchelder's coverage
215 module installed, you may activate a coverage report. The cover‐
216 age report will cover any python source module imported after
217 the start of the test run, excluding modules that match test‐
218 Match. If you want to include those modules too, use the
219 --covertests switch, or set the NOSE_COVER_TESTS environment
220 variable to a true value. To restrict the coverage report to
221 modules from a particular package or packages, use the
222 --cover-packages switch or the NOSE_COVER_PACKAGES environment
223 variable. [NOSE_WITH_COVERAGE]
224
225 --cover-package=COVER_PACKAGES
226 Restrict coverage output to selected packages [NOSE_COVER_PACK‐
227 AGE]
228
229 --cover-erase
230 Erase previously collected coverage statistics before run
231
232 --cover-tests
233 Include test modules in coverage report [NOSE_COVER_TESTS]
234
235 --cover-inclusive
236 Include all python files under working directory in coverage
237 report. Useful for discovering holes in test coverage if not
238 all files are imported by the test suite. [NOSE_COVER_INCLUSIVE]
239
240 --pdb Drop into debugger on errors
241
242 --pdb-failures
243 Drop into debugger on failures
244
245 --no-deprecated
246 Disable special handling of DeprecatedTest exceptions.
247
248 --with-doctest
249 Enable plugin Doctest: Activate doctest plugin to find and run
250 doctests in non-test modules. [NOSE_WITH_DOCTEST]
251
252 --doctest-tests
253 Also look for doctests in test modules [NOSE_DOCTEST_TESTS]
254
255 --doctest-extension=DOCTESTEXTENSION
256 Also look for doctests in files with this extension
257 [NOSE_DOCTEST_EXTENSION]
258
259 --with-isolation
260 Enable plugin IsolationPlugin: Activate the isolation plugin to
261 isolate changes to external modules to a single test module or
262 package. The isolation plugin resets the contents of sys.modules
263 after each test module or package runs to its state before the
264 test. PLEASE NOTE that this plugin should not be used with the
265 coverage plugin in any other case where module reloading may
266 produce undesirable side-effects. [NOSE_WITH_ISOLATION]
267
268 -d, --detailed-errors, --failure-detail
269 Add detail to error output by attempting to evaluate failed
270 asserts [NOSE_DETAILED_ERRORS]
271
272 --with-profile
273 Enable plugin Profile: Use this plugin to run tests using the
274 hotshot profiler. [NOSE_WITH_PROFILE]
275
276 --profile-sort=PROFILE_SORT
277 Set sort order for profiler output
278
279 --profile-stats-file=PROFILE_STATS_FILE
280 Profiler stats file; default is a new temp file on each run
281
282 --profile-restrict=PROFILE_RESTRICT
283 Restrict profiler output. See help for pstats.Stats for details
284
285 --no-skip
286 Disable special handling of SkipTest exceptions.
287
288 --with-id
289 Enable plugin TestId: Activate to add a test id (like #1) to
290 each test name output. After you've run once to generate test
291 ids, you can re-run individual tests by activating the plugin
292 and passing the ids (with or without the # prefix) instead of
293 test names. [NOSE_WITH_ID]
294
295 --id-file=TESTIDFILE
296 Store test ids found in test runs in this file.
297
299 nose is written by Jason Pellerin. This manpage was adapted from the
300 output of the help2man(1) program by Jason Pellerin, following the ver‐
301 sion made by Gustavo Noronha Silva for the Debian GNU/Linux system, but
302 may be used by others.
303
305 Copyright (C) 2005-2007 Jason Pellerin
306
307 This is free software. You may redistribute copies of it under the
308 terms of the GNU Lesser General Public License
309 <http://www.gnu.org/licenses/lgpl.html>. There is NO WARRANTY, to the
310 extent permitted by law.
311
313 The project website is at http://somethingaboutor‐
314 ange.com/mrl/projects/nose/
315
316
317
318
319nosetests version 0.10.0a1 July 2007 NOSETESTS(1)