# 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.

  `address`()

    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.

  `afterTest`(result)

    Called after test is complete (after result.stopTest)

  `beforeTest`(result)

    Called before test is run (before result.startTest)

  `context`

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

  `exc_info`()

    Extract exception info.

  `id`()

    Get a short(er) description of the test

  `run`(result)

    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.

  `runTest`(result)

    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.

  `shortDescription`()

    Returns a one-line description of the test, or None if no description has been provided.

    The default implementation of this method returns the first line of the specified test method’s docstring.

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.