Test Cases

nose unittest.TestCase subclasses. It is not necessary to subclass these classes when writing tests; they are used internally by nose.loader.TestLoader to create test cases from test functions and methods in test classes.

class nose.case.Test(test, config=None, resultProxy=None)

The universal test case wrapper.

When a plugin sees a test, it will always see an instance of this class. To access the actual test case that will be run, access the test property of the nose.case.Test instance.


Return a round-trip name for this test, a name that can be fed back as input to loadTestByName and (assuming the same plugin configuration) result in the loading of this test.


Called after test is complete (after result.stopTest)


Called before test is run (before result.startTest)


Get the context object of this test (if any).


Extract exception info.


Get a short(er) description of the test


Modified run for the test wrapper.

From here we don’t call result.startTest or stopTest or addSuccess. The wrapper calls addError/addFailure only if its own setup or teardown fails, or running the wrapped test fails (eg, if the wrapped “test” is not callable).

Two additional methods are called, beforeTest and afterTest. These give plugins a chance to modify the wrapped test before it is called and do cleanup after it is called. They are called unconditionally.


Run the test. Plugins may alter the test by returning a value from prepareTestCase. The value must be callable and must accept one argument, the result instance.

class nose.failure.Failure(exc_class, exc_val, tb=None, address=None)

Unloadable or unexecutable test.

A Failure case is placed in a test suite to indicate the presence of a test that could not be loaded or executed. A common example is a test module that fails to import.