nose: nose.case

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.

Classes

Highlighted methods are defined in this class.

Test (unittest.TestCase)

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.

Methods

__call__(self, *arg, **kwarg)
__init__(self, test, config=None, resultProxy=None)
_context(self)
_exc_info(self)(inherited from TestCase)

Return a version of sys.exc_info() with the traceback frame minimised; usually the top level of the traceback frame is not needed.

address(self)

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(self, result)

Called before test is run (before result.startTest)

assertAlmostEqual(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

assertAlmostEquals(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

assertEqual(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by the '==' operator.

assertEquals(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by the '==' operator.

assertFalse(self, expr, msg=None)(inherited from TestCase)

Fail the test if the expression is true.

assertNotAlmostEqual(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

assertNotAlmostEquals(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

assertNotEqual(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by the '==' operator.

assertNotEquals(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by the '==' operator.

assertRaises(self, excClass, callableObj, *args, **kwargs)(inherited from TestCase)

Fail unless an exception of class excClass is thrown by callableObj when invoked with arguments args and keyword arguments kwargs. If a different type of exception is thrown, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

assertTrue(self, expr, msg=None)(inherited from TestCase)

Fail the test unless the expression is true.

assert_(self, expr, msg=None)(inherited from TestCase)

Fail the test unless the expression is true.

beforeTest(self, result)

Called after test is complete (after result.stopTest)

countTestCases(self)(inherited from TestCase)
debug(self)(inherited from TestCase)

Run the test without collecting errors in a TestResult

defaultTestResult(self)(inherited from TestCase)
exc_info(self)

Extract exception info.

fail(self, msg=None)(inherited from TestCase)

Fail immediately, with the given message.

failIf(self, expr, msg=None)(inherited from TestCase)

Fail the test if the expression is true.

failIfAlmostEqual(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

failIfEqual(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by the '==' operator.

failUnless(self, expr, msg=None)(inherited from TestCase)

Fail the test unless the expression is true.

failUnlessAlmostEqual(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

failUnlessEqual(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by the '==' operator.

failUnlessRaises(self, excClass, callableObj, *args, **kwargs)(inherited from TestCase)

Fail unless an exception of class excClass is thrown by callableObj when invoked with arguments args and keyword arguments kwargs. If a different type of exception is thrown, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

id(self)

Get a short(er) description of the test

run(self, 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(self, 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.

setUp(self)(inherited from TestCase)

Hook method for setting up the test fixture before exercising it.

shortDescription(self)
tearDown(self)(inherited from TestCase)

Hook method for deconstructing the test fixture after testing it.

Attributes

context
Default value: (property)

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

TestBase (unittest.TestCase)

Common functionality for FunctionTestCase and MethodTestCase.

Methods

__call__(self, *args, **kwds)(inherited from TestCase)
__init__(self, methodName='runTest')(inherited from TestCase)

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

_exc_info(self)(inherited from TestCase)

Return a version of sys.exc_info() with the traceback frame minimised; usually the top level of the traceback frame is not needed.

assertAlmostEqual(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

assertAlmostEquals(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

assertEqual(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by the '==' operator.

assertEquals(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by the '==' operator.

assertFalse(self, expr, msg=None)(inherited from TestCase)

Fail the test if the expression is true.

assertNotAlmostEqual(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

assertNotAlmostEquals(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

assertNotEqual(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by the '==' operator.

assertNotEquals(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by the '==' operator.

assertRaises(self, excClass, callableObj, *args, **kwargs)(inherited from TestCase)

Fail unless an exception of class excClass is thrown by callableObj when invoked with arguments args and keyword arguments kwargs. If a different type of exception is thrown, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

assertTrue(self, expr, msg=None)(inherited from TestCase)

Fail the test unless the expression is true.

assert_(self, expr, msg=None)(inherited from TestCase)

Fail the test unless the expression is true.

countTestCases(self)(inherited from TestCase)
debug(self)(inherited from TestCase)

Run the test without collecting errors in a TestResult

defaultTestResult(self)(inherited from TestCase)
fail(self, msg=None)(inherited from TestCase)

Fail immediately, with the given message.

failIf(self, expr, msg=None)(inherited from TestCase)

Fail the test if the expression is true.

failIfAlmostEqual(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

failIfEqual(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by the '==' operator.

failUnless(self, expr, msg=None)(inherited from TestCase)

Fail the test unless the expression is true.

failUnlessAlmostEqual(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

failUnlessEqual(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by the '==' operator.

failUnlessRaises(self, excClass, callableObj, *args, **kwargs)(inherited from TestCase)

Fail unless an exception of class excClass is thrown by callableObj when invoked with arguments args and keyword arguments kwargs. If a different type of exception is thrown, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

id(self)
run(self, result=None)(inherited from TestCase)
runTest(self)
setUp(self)(inherited from TestCase)

Hook method for setting up the test fixture before exercising it.

shortDescription(self)
tearDown(self)(inherited from TestCase)

Hook method for deconstructing the test fixture after testing it.

MethodTestCase (TestBase)

Test case wrapper for test methods.

Don't use this class directly; it is used internally in nose to create test cases for test methods.

Methods

__call__(self, *args, **kwds)(inherited from TestCase)
__init__(self, method, test=None, arg=(), descriptor=None)

Initialize the MethodTestCase.

Required argument:

  • method -- the method to call, may be bound or unbound. In either case, a new instance of the method's class will be instantiated to make the call.

Optional arguments:

  • test -- the test function to call. If this is passed, it will be called instead of getting a new bound method of the same name as the desired method from the test instance. This is to support generator methods that yield inline functions.
  • arg -- arguments to pass to the test function. This is to support generator methods that yield arguments.
  • descriptor -- the function, other than the test, that should be used to construct the test name. This is to support generator methods.
_context(self)
_descriptors(self)

Get the descriptors of the test method: the method and arguments that will be used to construct the test name. In most cases, this is the method itself and no arguments. For tests generated by generator methods, the original (generator) method and args passed to the generated method or function are returned.

_exc_info(self)(inherited from TestCase)

Return a version of sys.exc_info() with the traceback frame minimised; usually the top level of the traceback frame is not needed.

address(self)

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.

assertAlmostEqual(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

assertAlmostEquals(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

assertEqual(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by the '==' operator.

assertEquals(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by the '==' operator.

assertFalse(self, expr, msg=None)(inherited from TestCase)

Fail the test if the expression is true.

assertNotAlmostEqual(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

assertNotAlmostEquals(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

assertNotEqual(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by the '==' operator.

assertNotEquals(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by the '==' operator.

assertRaises(self, excClass, callableObj, *args, **kwargs)(inherited from TestCase)

Fail unless an exception of class excClass is thrown by callableObj when invoked with arguments args and keyword arguments kwargs. If a different type of exception is thrown, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

assertTrue(self, expr, msg=None)(inherited from TestCase)

Fail the test unless the expression is true.

assert_(self, expr, msg=None)(inherited from TestCase)

Fail the test unless the expression is true.

countTestCases(self)(inherited from TestCase)
debug(self)(inherited from TestCase)

Run the test without collecting errors in a TestResult

defaultTestResult(self)(inherited from TestCase)
fail(self, msg=None)(inherited from TestCase)

Fail immediately, with the given message.

failIf(self, expr, msg=None)(inherited from TestCase)

Fail the test if the expression is true.

failIfAlmostEqual(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

failIfEqual(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by the '==' operator.

failUnless(self, expr, msg=None)(inherited from TestCase)

Fail the test unless the expression is true.

failUnlessAlmostEqual(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

failUnlessEqual(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by the '==' operator.

failUnlessRaises(self, excClass, callableObj, *args, **kwargs)(inherited from TestCase)

Fail unless an exception of class excClass is thrown by callableObj when invoked with arguments args and keyword arguments kwargs. If a different type of exception is thrown, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

id(self)(inherited from TestBase)
run(self, result=None)(inherited from TestCase)
runTest(self)(inherited from TestBase)
setUp(self)
shortDescription(self)(inherited from TestBase)
tearDown(self)

Attributes

context
Default value: (property)

Get context (class) of this test

FunctionTestCase (TestBase)

TestCase wrapper for test functions.

Don't use this class directly; it is used internally in nose to create test cases for test functions.

Methods

__call__(self, *args, **kwds)(inherited from TestCase)
__init__(self, test, setUp=None, tearDown=None, arg=(), descriptor=None)

Initialize the MethodTestCase.

Required argument:

  • test -- the test function to call.

Optional arguments:

  • setUp -- function to run at setup.
  • tearDown -- function to run at teardown.
  • arg -- arguments to pass to the test function. This is to support generator functions that yield arguments.
  • descriptor -- the function, other than the test, that should be used to construct the test name. This is to support generator functions.
_context(self)
_descriptors(self)

Get the descriptors of the test function: the function and arguments that will be used to construct the test name. In most cases, this is the function itself and no arguments. For tests generated by generator functions, the original (generator) function and args passed to the generated function are returned.

_exc_info(self)(inherited from TestCase)

Return a version of sys.exc_info() with the traceback frame minimised; usually the top level of the traceback frame is not needed.

address(self)

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.

assertAlmostEqual(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

assertAlmostEquals(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

assertEqual(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by the '==' operator.

assertEquals(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by the '==' operator.

assertFalse(self, expr, msg=None)(inherited from TestCase)

Fail the test if the expression is true.

assertNotAlmostEqual(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

assertNotAlmostEquals(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

assertNotEqual(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by the '==' operator.

assertNotEquals(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by the '==' operator.

assertRaises(self, excClass, callableObj, *args, **kwargs)(inherited from TestCase)

Fail unless an exception of class excClass is thrown by callableObj when invoked with arguments args and keyword arguments kwargs. If a different type of exception is thrown, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

assertTrue(self, expr, msg=None)(inherited from TestCase)

Fail the test unless the expression is true.

assert_(self, expr, msg=None)(inherited from TestCase)

Fail the test unless the expression is true.

countTestCases(self)(inherited from TestCase)
debug(self)(inherited from TestCase)

Run the test without collecting errors in a TestResult

defaultTestResult(self)(inherited from TestCase)
fail(self, msg=None)(inherited from TestCase)

Fail immediately, with the given message.

failIf(self, expr, msg=None)(inherited from TestCase)

Fail the test if the expression is true.

failIfAlmostEqual(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

failIfEqual(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are equal as determined by the '==' operator.

failUnless(self, expr, msg=None)(inherited from TestCase)

Fail the test unless the expression is true.

failUnlessAlmostEqual(self, first, second, places=7, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit).

failUnlessEqual(self, first, second, msg=None)(inherited from TestCase)

Fail if the two objects are unequal as determined by the '==' operator.

failUnlessRaises(self, excClass, callableObj, *args, **kwargs)(inherited from TestCase)

Fail unless an exception of class excClass is thrown by callableObj when invoked with arguments args and keyword arguments kwargs. If a different type of exception is thrown, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

id(self)(inherited from TestBase)
run(self, result=None)(inherited from TestCase)
runTest(self)(inherited from TestBase)
setUp(self)

Run any setup function attached to the test function

shortDescription(self)(inherited from TestBase)
tearDown(self)

Run any teardown function attached to the test function

Attributes

context
Default value: (property)

Get context (module) of this test