| |
- TestCase
-
- FunctionTestCase
- TestLoader
- TestProgram
- TestResult
-
- _TextTestResult
- TestSuite
- TextTestRunner
- _WritelnDecorator
class TestCase |
|
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.
|
| |
- __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.
- __call__(self, result=None)
- no doc string
- __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.
- __repr__(self)
- no doc string
- __str__(self)
- no doc string
- failUnlessEqual(self, first, second, msg=None)
- Fail if the two objects are unequal as determined by the '!='
- operator.
- failUnlessEqual(self, first, second, msg=None)
- Fail if the two objects are unequal as determined by the '!='
- operator.
- failIfEqual(self, first, second, msg=None)
- Fail if the two objects are equal as determined by the '=='
- operator.
- failIfEqual(self, first, second, msg=None)
- Fail if the two objects are equal 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. 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.
- failUnless(self, expr, msg=None)
- Fail the test unless the expression is true.
- countTestCases(self)
- no doc string
- debug(self)
- Run the test without collecting errors in a TestResult
- defaultTestResult(self)
- no doc string
- fail(self, msg=None)
- Fail immediately, with the given message.
- failIf(self, expr, msg=None)
- Fail the test if the expression is true.
- failIfEqual(self, first, second, msg=None)
- Fail if the two objects are equal as determined by the '=='
- operator.
- failUnless(self, expr, msg=None)
- Fail the test unless the expression is true.
- failUnlessEqual(self, first, second, msg=None)
- 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. 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)
- no doc string
- run(self, result=None)
- no doc string
- 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.
-
- The default implementation of this method returns the first line of
- the specified test method's docstring.
- tearDown(self)
- Hook method for deconstructing the test fixture after testing it.
|
class TestLoader |
|
This class is responsible for loading tests according to various
criteria and returning them wrapped in a Test
|
| |
- getTestCaseNames(self, testCaseClass)
- Return a sorted sequence of method names found within testCaseClass
- loadTestsFromModule(self, module)
- Return a suite of all tests cases contained in the given module
- loadTestsFromName(self, name, module=None)
- Return a suite of all tests cases given a string specifier.
-
- The name may resolve either to a module, a test case class, a
- test method within a test case class, or a callable object which
- returns a TestCase or TestSuite instance.
-
- The method optionally resolves the names relative to a given module.
- loadTestsFromNames(self, names, module=None)
- Return a suite of all tests cases found using the given sequence
- of string specifiers. See 'loadTestsFromName()'.
- loadTestsFromTestCase(self, testCaseClass)
- Return a suite of all tests cases contained in testCaseClass
|
class TestResult |
|
Holder for test result information.
Test results are automatically managed by the TestCase and TestSuite
classes, and do not need to be explicitly manipulated by writers of tests.
Each instance holds the total number of tests run, and collections of
failures and errors that occurred among those test runs. The collections
contain tuples of (testcase, exceptioninfo), where exceptioninfo is a
tuple of values as returned by sys.exc_info().
|
| |
- __init__(self)
- no doc string
- __repr__(self)
- no doc string
- addError(self, test, err)
- Called when an error has occurred
- addFailure(self, test, err)
- Called when a failure has occurred
- addSuccess(self, test)
- Called when a test has completed successfully
- startTest(self, test)
- Called when the given test is about to be run
- stop(self)
- Indicates that the tests should be aborted
- stopTest(self, test)
- Called when the given test has been run
- wasSuccessful(self)
- Tells whether or not this result was a success
|
class TestSuite |
|
A test suite is a composite test consisting of a number of TestCases.
For use, create an instance of TestSuite, then add test case instances.
When all tests have been added, the suite can be passed to a test
runner, such as TextTestRunner. It will run the individual test cases
in the order in which they were added, aggregating the results. When
subclassing, do not forget to call the base class constructor.
|
| |
- __call__(self, result)
- no doc string
- __init__(self, tests=())
- no doc string
- __repr__(self)
- no doc string
- __repr__(self)
- no doc string
- addTest(self, test)
- no doc string
- addTests(self, tests)
- no doc string
- countTestCases(self)
- no doc string
- debug(self)
- Run the tests without collecting errors in a TestResult
- run(self, result)
- no doc string
|
class _TextTestResult(TestResult) |
|
A test result class that can print formatted text results to a stream.
Used by TextTestRunner.
|
| |
- __init__(self, stream, descriptions, verbosity)
- no doc string
- addError(self, test, err)
- no doc string
- addFailure(self, test, err)
- no doc string
- addSuccess(self, test)
- no doc string
- getDescription(self, test)
- no doc string
- printErrorList(self, flavour, errors)
- no doc string
- printErrors(self)
- no doc string
- startTest(self, test)
- no doc string
|
|