usage: nosetests [options] [names]
nose provides an alternate test discovery and running process for
unittest, one that is intended to mimic the behavior of py.test as much as
is reasonably possible without resorting to magic.
nose collects tests automatically from python source files,
directories and packages found in its working directory (which
defaults to the current working directory). Any python source file,
directory or package that matches the testMatch regular expression
(by default: (?:^|[_\.-])[Tt]est) will be collected as a test (or
source for collection of tests). In addition, all other packages
found in the working directory are examined for python source files
or directories that match testMatch. Package discovery descends all
the way down the tree, so package.tests and package.sub.tests and
package.sub.sub2.tests will all be collected.
Within a test directory or package, any python source file matching
testMatch will be examined for test cases. Within a test file,
functions and classes whose names match testMatch and TestCase
subclasses with any name will be loaded and executed as tests. Tests
may use the assert keyword or raise AssertionErrors to indicate test
failure. TestCase subclasses may do the same or use the various
TestCase methods available.
Tests may raise nose.SkipTest to indicate that they should be
skipped or nose.DeprecatedTest to indicate that they are
deprecated. Skipped and deprecated tests do not count as failures,
but details on them are printed at the end of the test run along
with any failures and errors.
Selecting Tests
---------------
To specify which tests to run, pass test names on the command line:
nosetests only_test_this.py
Test names specified may be file or module names, and may optionally
indicate the test case to run by separating the module or file name
from the test case name with a colon. Filenames may be relative or
absolute. Examples:
nosetests test.module
nosetests another.test:TestCase.test_method
nosetests a.test:TestCase
nosetests /path/to/test/file.py:test_function
Note however that specifying a test name will *not* cause nose to run
a test that it does not discover. Test names specified are compared
against tests discovered, and only the requested tests are
run. Setup and teardown methods are run at all stages. That means
that if you run:
nosetests some.tests.test_module:test_function
And have defined setup or teardown methods in tests and test_module,
those setup methods will run before the test_function test, and
teardown after, just as if you were running all tests.
You may also change the working directory where nose looks for tests,
use the -w switch:
nosetests -w /path/to/tests
Further customization of test selection and loading is possible
through the use of plugins.
Test result output is identical to that of unittest, except for the
additional features (output capture, assert introspection, and any plugins
that control or produce output) detailed in the options below.
options:
-h, --help show this help message and exit
-V, --version Output nose version and exit
-v, --verbose Be more verbose. [NOSE_VERBOSE]
--verbosity=VERBOSITY
Set verbosity; --verbosity=2 is the same as -vv
-l DEBUG, --debug=DEBUG
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.
--debug-log=DEBUG_LOG
Log debug messages to this file (default: sys.stderr)
-q, --quiet
-w WHERE, --where=WHERE
Look for tests in this directory [NOSE_WHERE]
-e EXCLUDE, --exclude=EXCLUDE
Don't run tests that match regular expression
[NOSE_EXCLUDE]
-i INCLUDE, --include=INCLUDE
Also run tests that match regular expression
[NOSE_INCLUDE]
-s, --nocapture Don't capture stdout (any stdout output will be
printed immediately) [NOSE_NOCAPTURE]
-d, --detailed-errors
Add detail to error output by attempting to evaluate
failed asserts [NOSE_DETAILED_ERRORS]
--pdb Drop into debugger on errors
--pdb-failures Drop into debugger on failures
-x, --stop Stop running tests after the first error or failure
-P, --no-path-adjustment
Don't make any changes to sys.path when loading tests
[NOSE_NOPATH]
--exe 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]
--noexe DO NOT look for tests in python modules that are
executable. (The default on the windows platform is to
do so.)
--with-stopwatch Enable plugin Stopwatch: (no help available)
[NOSE_WITH_STOPWATCH]
--faster-than=FASTER_THAN
Run only tests that are faster than FASTER_THAN
seconds.
--stopwatch-file=STOPWATCH_FILE
Store test timing results in this file.
--with-decorator Enable plugin Decorator: (no help available)
[NOSE_WITH_DECORATOR]
--decorator-file=DECORATOR_FILE
Apply attributes in this file to matching functions
--with-django Enable plugin NoseDjango: Enable to set up django
test environment before running all tests, and tear it
down after all tests. If the django database engine in
use is not sqlite3, one or both of --django-test-db or
django-test-schema must be specified. Note that your
django project must be on PYTHONPATH for the settings
file to be loaded. The plugin will help out by placing
the nose working dir into sys.path if it isn't already
there, unless the -P (--no-path-adjustment) argument
is set. [NOSE_WITH_DJANGO]
--django-settings=DJANGO_SETTINGS
Set module as the DJANGO_SETTINGS_MODULE environment
variable.
--django-test-db=DJANGO_TEST_DB
Create this database for use in tests and drop it
after tests have run. May be combined with --django-
test-schema option for databases that support schemas.
This option is not used for sqlite3 connections.
PLEASE NOTE that if the test database already exists,
the test run will be immediately cancelled.
[NOSE_DJANGO_TEST_DB]
--django-test-schema=DJANGO_TEST_SCHEMA
Create this schema for use in tests and drop it after
tests have run. May be combined with --django-test-db;
otherwise, test schema will be created in the database
named by DATABASE_NAME in the active django settings.
This option is not used for sqlite3 connections.
PLEASE NOTE that if the specified schema already
exists in the target database, the test run will be
immediately cancelled. [NOSE_DJANGO_TEST_SCHEMA]
--with-watch Enable plugin NoseWatch: watch failing tests, re-test
when imported code is modified [NOSE_WITH_WATCH]
--with-profile Enable plugin Profile: Use this plugin to run tests
using the hotshot profiler. [NOSE_WITH_PROFILE]
--profile-sort=PROFILE_SORT
Set sort order for profiler output
--profile-stats-file=PROFILE_STATS_FILE
Profiler stats file; default is a new temp file on
each run
--profile-restrict=PROFILE_RESTRICT
Restrict profiler output. See help for pstats.Stats
for details
-a ATTR, --attr=ATTR Run only tests that have attributes specified by ATTR
[NOSE_ATTR]
-A EXPR, --eval-attr=EXPR
Run only tests for whose attributes the Python
expression EXPR evaluates to True [NOSE_EVAL_ATTR]
--with-doctest Enable plugin Doctest: Activate doctest plugin to
find and run doctests in non-test modules.
[NOSE_WITH_DOCTEST]
--doctest-tests Also look for doctests in test modules
[NOSE_DOCTEST_TESTS]
--doctest-extension=DOCTESTEXTENSION
Also look for doctests in files with this extension
[NOSE_DOCTEST_EXTENSION]
--with-coverage Enable plugin Coverage: If you have Ned Batchelder's
coverage module installed, you may activate a coverage
report. The coverage report will cover any python
source module imported after the start of the test
run, excluding modules that match testMatch. If you
want to include those modules too, use the --cover-
tests switch, or set the NOSE_COVER_TESTS environment
variable to a true value. To restrict the coverage
report to modules from a particular package or
packages, use the --cover-packages switch or the
NOSE_COVER_PACKAGES environment variable.
[NOSE_WITH_COVERAGE]
--cover-package=COVER_PACKAGES
Restrict coverage output to selected packages
[NOSE_COVER_PACKAGE]
--cover-erase Erase previously collected coverage statistics before
run
--cover-tests Include test modules in coverage report
[NOSE_COVER_TESTS]
--cover-inclusive 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]
--with-missed-tests Enable plugin MissedTests: Enable to get a warning
when tests specified on the command line are not found
during the test run. [NOSE_WITH_MISSED-TESTS]