nose: nose.suite

Provides a LazySuite, which is a suite whose test list is a generator function, and ContextSuite, a suite that can run fixtures (setup/teardown functions or methods) for the context that contains its tests.

Classes

Highlighted methods are defined in this class.

FinalizingSuiteWrapper (unittest.TestSuite)

Wraps suite and calls final function after suite has executed. Used to call final functions in cases (like running in the standard test runner) where test running is not under nose's control.

Methods

__call__(self, *arg, **kw)
__init__(self, suite, finalize)
__iter__(self)(inherited from TestSuite)
addTest(self, test)(inherited from TestSuite)
addTests(self, tests)(inherited from TestSuite)
countTestCases(self)(inherited from TestSuite)
debug(self)(inherited from TestSuite)

Run the tests without collecting errors in a TestResult

run(self, *arg, **kw)
ContextSuite (LazySuite)

A suite with context.

A ContextSuite executes fixtures (setup and teardown functions or methods) for the context containing its tests.

The context may be explicitly passed. If it is not, a context (or nested set of contexts) will be constructed by examining the tests in the suite.

Methods

__call__(self, *arg, **kw)
__init__(self, tests=(), context=None, factory=None, config=None, resultProxy=None)
__iter__(self)(inherited from LazySuite)
__nonzero__(self)(inherited from LazySuite)
_get_tests(self)(inherited from LazySuite)
_get_wrapped_tests(self)
_set_tests(self, tests)(inherited from LazySuite)
addTest(self, test)(inherited from LazySuite)
addTests(self, tests)(inherited from TestSuite)
countTestCases(self)(inherited from TestSuite)
debug(self)(inherited from TestSuite)

Run the tests without collecting errors in a TestResult

exc_info(self)

Hook for replacing error tuple output

run(self, result)

Run tests in suite inside of suite fixtures.

setUp(self)
setupContext(self, context)
shortDescription(self)
tearDown(self)
teardownContext(self, context)

Attributes

_tests
Default value: (property)

Access the tests in this suite. Tests are returned inside of a context wrapper.

was_setup
Default value: False
was_torndown
Default value: False
ContextSuiteFactory (object)

Factory for ContextSuites. Called with a collection of tests, the factory decides on a hierarchy of contexts by introspecting the collection or the tests them selves to find the objects containing the test objects. It always returns one suite, but that suite may consist of a hierarchy of nested suites.

Methods

__call__(self, tests)

Return ContextSuite for tests. tests may either be a callable (in which case the resulting ContextSuite will have no parent context and be evaluated lazily) or an iterable. In that case the tests will wrapped in nose.case.Test, be examined and the context of each found and a suite of suites returned, organized into a stack with the outermost suites belonging to the outermost contexts.

__init__(self, config=None, suiteClass=None, resultProxy=)
ancestry(self, context)

Return the ancestry of the context (that is, all of the packages and modules containing the context), in order of descent with the outermost ancestor last. This method is a generator.

findContext(self, tests)
makeSuite(self, tests, context)
mixedSuites(self, tests)

The complex case where there are tests that don't all share the same context. Groups tests into suites with common ancestors, according to the following (essentially tail-recursive) procedure:

Starting with the context of the first test, if it is not None, look for tests in the remaining tests that share that ancestor. If any are found, group into a suite with that ancestor as the context, and replace the current suite with that suite. Continue this process for each ancestor of the first test, until all ancestors have been processed. At this point if any tests remain, recurse with those tests as the input, returning a list of the common suite (which may be the suite or test we started with, if no common tests were found) plus the results of recursion.

wrapTests(self, tests)
TestModule ()

Methods

__init__(*arg, **kw)
ContextList (object)

Not quite a suite -- a group of tests in a context. This is used to hint the ContextSuiteFactory about what context the tests belong to, in cases where it may be ambiguous or missing.

Methods

__init__(self, tests, context=None)
__iter__(self)
LazySuite (unittest.TestSuite)

A suite that may use a generator as its list of tests

Methods

__call__(self, *args, **kwds)(inherited from TestSuite)
__init__(self, tests=())

Initialize the suite. tests may be an iterable or a generator

__iter__(self)
__nonzero__(self)
_get_tests(self)
_set_tests(self, tests)
addTest(self, test)
addTests(self, tests)(inherited from TestSuite)
countTestCases(self)(inherited from TestSuite)
debug(self)(inherited from TestSuite)

Run the tests without collecting errors in a TestResult

run(self, result)(inherited from TestSuite)

Attributes

_tests
Default value: (property)

Access the tests in this suite. Access is through a generator, so iteration may not be repeatable.

MixedContextError (exceptions.Exception)

Error raised when a context suite sees tests from more than one context.

Methods

__getitem__(...)(inherited from Exception)
__init__(...)(inherited from Exception)
TestDir ()

Methods

__init__(*arg, **kw)

Attributes

log
Default value: <logging.Logger instance>
generators
Default value: _Feature((2, 2, 0, 'alpha', 1), (2, 3, 0, 'final', 0), 4096)