Testing with nose¶
Writing tests is easier¶
nose collects tests from unittest.TestCase
subclasses, of course. But
you can also write simple test functions, as well as test classes that are
not subclasses of unittest.TestCase
. nose also supplies a number of
helpful functions for writing timed tests, testing for exceptions, and other
common use cases. See Writing tests and Testing tools for more.
Running tests is easier¶
nose collects tests automatically, as long as you follow some simple guidelines for organizing your library and test code. There’s no need to manually collect test cases into test suites. Running tests is responsive, since nose begins running tests as soon as the first test module is loaded. See Finding and running tests for more.
Setting up your test environment is easier¶
nose supports fixtures at the package, module, class, and test case level, so expensive initialization can be done as infrequently as possible. See Fixtures for more.
Doing what you want to do is easier¶
nose comes with a number of builtin plugins to help you with output capture, error introspection, code coverage, doctests, and more. It also comes with plugin hooks for loading, running, watching and reporting on tests and test runs. If you don’t like the default collection scheme, or it doesn’t suit the layout of your project, or you need reports in a format different from the unittest standard, or you need to collect some additional information about tests (like code coverage or profiling data), you can write a plugin to make nose do what you want. See the section on Writing Plugins for more. There are also many third-party nose plugins available.
Details¶
- Basic usage
- Writing tests
- Finding and running tests
- Testing tools
- Tools for testing
TimeExpired
assert_almost_equal()
assert_count_equal()
assert_dict_contains_subset()
assert_equal()
assert_false()
assert_greater()
assert_greater_equal()
assert_in()
assert_is()
assert_is_instance()
assert_is_none()
assert_is_not()
assert_is_not_none()
assert_less()
assert_less_equal()
assert_list_equal()
assert_logs()
assert_multi_line_equal()
assert_no_logs()
assert_not_almost_equal()
assert_not_equal()
assert_not_in()
assert_not_is_instance()
assert_not_regex()
assert_raises()
assert_raises_regex()
assert_regex()
assert_sequence_equal()
assert_set_equal()
assert_true()
assert_tuple_equal()
assert_warns()
assert_warns_regex()
eq_()
istest()
make_decorator()
nottest()
ok_()
raises()
set_trace()
timed()
with_setup()
- Batteries included: builtin nose plugins
- AllModules: collect tests in all modules
- Attrib: tag and select tests with attributes
- Capture: capture stdout during tests
- Collect: Collect tests quickly
- Cover: code coverage
- Debug: drop into pdb on errors or failures
- Deprecated: mark tests as deprecated
- Doctests: run doctests with nose
- Failure Detail: introspect asserts
- Isolate: protect tests from (some) side-effects
- Logcapture: capture logging during tests
- Multiprocess: parallel testing
- Prof: enable profiling using the hotshot profiler
- Skip: mark tests as skipped
- Testid: add a test id to each test name output
- Xunit: output test results in xunit format
- Third-party nose plugins
- Setuptools integration