unittest.TestCase

unittest :: TestCase :: Class TestCase |
[hide private]
[frames] | no frames]

# Class TestCase

source code

    object --+
             |
            TestCase

Known Subclasses:
  gchecky.test.gxml'.XmlFieldTestCase, gchecky.test.gxml'.XmlNodeTestCase, FunctionTestCase, gchecky.test.controller.ControllerTestCase

A class whose instances are single test cases.

By default, the test code itself should be placed in a method named 'runTest'.

If the fixture may be used for many test cases, create as many test methods as are needed. When instantiating such a TestCase subclass, specify in the constructor arguments the name of the test method that the instance is to execute.

Test authors should subclass TestCase for their own tests. Construction and deconstruction of the test's environment ('fixture') can be implemented by overriding the 'setUp' and 'tearDown' methods respectively.

If it is necessary to override the __init__ method, the base class __init__ method must always be called. It is important that subclasses should not change the signature of their __init__ method, since instances of the classes are instantiated automatically by parts of the framework in order to be run.

Nested Classes | [hide private]
| failureException Assertion failed.

Instance Methods | [hide private]
__init__(self, methodName=`'``runTest``'`) Create an instance of the class that will use the named test method when executed. | source code
setUp(self) Hook method for setting up the test fixture before exercising it. | source code
tearDown(self) Hook method for deconstructing the test fixture after testing it. | source code
countTestCases(self) | source code
defaultTestResult(self) | source code
shortDescription(self) Returns a one-line description of the test, or None if no description has been provided. | source code
id(self) | source code
__str__(self) str(x) | source code
__repr__(self) repr(x) | source code
run(self, result=None) | source code
__call__(self, *args, **kwds) | source code
debug(self) Run the test without collecting errors in a TestResult | source code
_exc_info(self) Return a version of sys.exc_info() with the traceback frame minimised; usually the top level of the traceback frame is not needed. | source code
fail(self, msg=None) Fail immediately, with the given message. | source code
failIf(self, expr, msg=None) Fail the test if the expression is true. | source code
failUnless(self, expr, msg=None) Fail the test unless the expression is true. | source code
failUnlessRaises(self, excClass, callableObj, *args, **kwargs) Fail unless an exception of class excClass is thrown by callableObj when invoked with arguments args and keyword arguments kwargs. | source code
failUnlessEqual(self, first, second, msg=None) Fail if the two objects are unequal as determined by the '==' operator. | source code
failIfEqual(self, first, second, msg=None) Fail if the two objects are equal as determined by the '==' operator. | source code
failUnlessAlmostEqual(self, first, second, places=7, msg=None) 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. | source code
failIfAlmostEqual(self, first, second, places=7, msg=None) 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. | source code
assertEquals(self, first, second, msg=None) Fail if the two objects are unequal as determined by the '==' operator. | source code
assertEqual(self, first, second, msg=None) Fail if the two objects are unequal as determined by the '==' operator. | source code
assertNotEquals(self, first, second, msg=None) Fail if the two objects are equal as determined by the '==' operator. | source code
assertNotEqual(self, first, second, msg=None) Fail if the two objects are equal as determined by the '==' operator. | source code
assertAlmostEquals(self, first, second, places=7, msg=None) 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. | source code
assertAlmostEqual(self, first, second, places=7, msg=None) 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. | source code
assertNotAlmostEquals(self, first, second, places=7, msg=None) 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. | source code
assertNotAlmostEqual(self, first, second, places=7, msg=None) 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. | source code
assertRaises(self, excClass, callableObj, *args, **kwargs) Fail unless an exception of class excClass is thrown by callableObj when invoked with arguments args and keyword arguments kwargs. | source code
assertTrue(self, expr, msg=None) Fail the test unless the expression is true. | source code
assert_(self, expr, msg=None) Fail the test unless the expression is true. | source code
assertFalse(self, expr, msg=None) Fail the test if the expression is true. | source code
Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, methodName=`'``runTest``'`) (Constructor) | source code
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. Overrides: object.__init__

### shortDescription(self) | source code
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.

### __str__(self) (Informal representation operator) | source code
str(x) Overrides: object.__str__ (inherited documentation)

### __repr__(self) (Representation operator) | source code
repr(x) Overrides: object.__repr__ (inherited documentation)

### failUnlessRaises(self, excClass, callableObj, *args, **kwargs) | source code
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.

### failUnlessAlmostEqual(self, first, second, places=7, msg=None) | source code
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).

### failIfAlmostEqual(self, first, second, places=7, msg=None) | source code
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).

### assertAlmostEquals(self, first, second, places=7, msg=None) | source code
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).

### assertAlmostEqual(self, first, second, places=7, msg=None) | source code
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).

### assertNotAlmostEquals(self, first, second, places=7, msg=None) | source code
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).

### assertNotAlmostEqual(self, first, second, places=7, msg=None) | source code
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).

### assertRaises(self, excClass, callableObj, *args, **kwargs) | source code
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.