[frames | no frames] [show private | hide private]

unittest
Class TestCase

Known Subclasses:
ContextStackTests, ContextChainTests, ContextTests, DependencyVersionTests, InstallEngineTests, DependencyGraphTest, PoolTests

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.
Method Summary
  __init__(self, methodName)
Create an instance of the class that will use the named test method when executed.
  __call__(self, result)
  __repr__(self)
  __str__(self)
  assert_(self, expr, msg)
Fail the test unless the expression is true.
  assertEqual(self, first, second, msg)
Fail if the two objects are unequal as determined by the '!=' operator.
  assertEquals(self, first, second, msg)
Fail if the two objects are unequal as determined by the '!=' operator.
  assertNotEqual(self, first, second, msg)
Fail if the two objects are equal as determined by the '==' operator.
  assertNotEquals(self, first, second, msg)
Fail if the two objects are equal as determined by the '==' operator.
  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.
  countTestCases(self)
  debug(self)
Run the test without collecting errors in a TestResult
  defaultTestResult(self)
  fail(self, msg)
Fail immediately, with the given message.
  failIf(self, expr, msg)
Fail the test if the expression is true.
  failIfEqual(self, first, second, msg)
Fail if the two objects are equal as determined by the '==' operator.
  failUnless(self, expr, msg)
Fail the test unless the expression is true.
  failUnlessEqual(self, first, second, msg)
Fail if the two objects are unequal as determined by the '!=' operator.
  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.
  id(self)
  run(self, result)
  setUp(self)
Hook method for setting up the test fixture before exercising it.
  shortDescription(self)
Returns a one-line description of the test, or None if no description has been provided.
  tearDown(self)
Hook method for deconstructing the test fixture after testing it.

Class Variable Summary
class AssertionError

Method Details

Constructor

__init__(self, methodName='runTest')

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.

Call operator

__call__(self, result=None)

Representation operator

__repr__(self)

Informal representation operator

__str__(self)

assert_

assert_(self, expr, msg=None)

Fail the test unless the expression is true.

assertEqual

assertEqual(self, first, second, msg=None)

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

assertEquals

assertEquals(self, first, second, msg=None)

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

assertNotEqual

assertNotEqual(self, first, second, msg=None)

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

assertNotEquals

assertNotEquals(self, first, second, msg=None)

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

assertRaises

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

countTestCases

countTestCases(self)

debug

debug(self)

Run the test without collecting errors in a TestResult

defaultTestResult

defaultTestResult(self)

fail

fail(self, msg=None)

Fail immediately, with the given message.

failIf

failIf(self, expr, msg=None)

Fail the test if the expression is true.

failIfEqual

failIfEqual(self, first, second, msg=None)

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

failUnless

failUnless(self, expr, msg=None)

Fail the test unless the expression is true.

failUnlessEqual

failUnlessEqual(self, first, second, msg=None)

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

failUnlessRaises

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

id(self)

run

run(self, result=None)

setUp

setUp(self)

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

shortDescription

shortDescription(self)

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.

tearDown

tearDown(self)

Hook method for deconstructing the test fixture after testing it.

Class Variable Details

AssertionError

AssertionError = exceptions.AssertionError

Generated by Epydoc 1.1 on Mon Oct 21 19:45:06 2002 http://epydoc.sf.net