Test Suites

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

class nose.suite.ContextList(tests, context=None)

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.

class nose.suite.ContextSuite(tests=(), context=None, factory=None, config=None, resultProxy=None, can_split=True)

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.

exc_info()

Hook for replacing error tuple output

failureException

alias of AssertionError

run(result)

Run tests in suite inside of suite fixtures.

class nose.suite.ContextSuiteFactory(config=None, suiteClass=None, resultProxy=<object 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 themselves to find the objects containing the test objects. It always returns one suite, but that suite may consist of a hierarchy of nested suites.

ancestry(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.

mixedSuites(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.

suiteClass

alias of ContextSuite

class nose.suite.FinalizingSuiteWrapper(suite, finalize)

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.

class nose.suite.LazySuite(tests=())

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

exception nose.suite.MixedContextError

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