Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
unittest.runner.TextTestResult Class Reference
Inheritance diagram for unittest.runner.TextTestResult:
Inheritance graph
[legend]
Collaboration diagram for unittest.runner.TextTestResult:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def getDescription
def startTest
def addSuccess
def addError
def addFailure
def addSkip
def addExpectedFailure
def addUnexpectedSuccess
def printErrors
def printErrorList
def startTestRun
def stopTest
def stopTestRun
def wasSuccessful
def stop
def __repr__

Public Attributes

 stream
 showAll
 dots
 descriptions
 failfast
 failures
 errors
 testsRun
 skipped
 expectedFailures
 unexpectedSuccesses
 shouldStop
 buffer
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Static Public Attributes

string separator1 = '='
string separator2 = '-'

Detailed Description

A test result class that can print formatted text results to a stream.

Used by TextTestRunner.

Definition at line 29 of file runner.py.


Constructor & Destructor Documentation

def unittest.runner.TextTestResult.__init__ (   self,
  stream,
  descriptions,
  verbosity 
)

Reimplemented from unittest.result.TestResult.

Definition at line 37 of file runner.py.

00037 
00038     def __init__(self, stream, descriptions, verbosity):
00039         super(TextTestResult, self).__init__()
00040         self.stream = stream
00041         self.showAll = verbosity > 1
00042         self.dots = verbosity == 1
00043         self.descriptions = descriptions

Here is the caller graph for this function:


Member Function Documentation

def unittest.result.TestResult.__repr__ (   self) [inherited]

Definition at line 189 of file result.py.

00189 
00190     def __repr__(self):
00191         return ("<%s run=%i errors=%i failures=%i>" %
00192                (util.strclass(self.__class__), self.testsRun, len(self.errors),
00193                 len(self.failures)))
def unittest.runner.TextTestResult.addError (   self,
  test,
  err 
)
Called when an error has occurred. 'err' is a tuple of values as
returned by sys.exc_info().

Reimplemented from unittest.result.TestResult.

Definition at line 66 of file runner.py.

00066 
00067     def addError(self, test, err):
00068         super(TextTestResult, self).addError(test, err)
00069         if self.showAll:
00070             self.stream.writeln("ERROR")
00071         elif self.dots:
00072             self.stream.write('E')
00073             self.stream.flush()

def unittest.runner.TextTestResult.addExpectedFailure (   self,
  test,
  err 
)
Called when an expected failure/error occured.

Reimplemented from unittest.result.TestResult.

Definition at line 90 of file runner.py.

00090 
00091     def addExpectedFailure(self, test, err):
00092         super(TextTestResult, self).addExpectedFailure(test, err)
00093         if self.showAll:
00094             self.stream.writeln("expected failure")
00095         elif self.dots:
00096             self.stream.write("x")
00097             self.stream.flush()

def unittest.runner.TextTestResult.addFailure (   self,
  test,
  err 
)
Called when an error has occurred. 'err' is a tuple of values as
returned by sys.exc_info().

Reimplemented from unittest.result.TestResult.

Definition at line 74 of file runner.py.

00074 
00075     def addFailure(self, test, err):
00076         super(TextTestResult, self).addFailure(test, err)
00077         if self.showAll:
00078             self.stream.writeln("FAIL")
00079         elif self.dots:
00080             self.stream.write('F')
00081             self.stream.flush()

def unittest.runner.TextTestResult.addSkip (   self,
  test,
  reason 
)
Called when a test is skipped.

Reimplemented from unittest.result.TestResult.

Definition at line 82 of file runner.py.

00082 
00083     def addSkip(self, test, reason):
00084         super(TextTestResult, self).addSkip(test, reason)
00085         if self.showAll:
00086             self.stream.writeln("skipped {0!r}".format(reason))
00087         elif self.dots:
00088             self.stream.write("s")
00089             self.stream.flush()

def unittest.runner.TextTestResult.addSuccess (   self,
  test 
)

Reimplemented from unittest.result.TestResult.

Definition at line 58 of file runner.py.

00058 
00059     def addSuccess(self, test):
00060         super(TextTestResult, self).addSuccess(test)
00061         if self.showAll:
00062             self.stream.writeln("ok")
00063         elif self.dots:
00064             self.stream.write('.')
00065             self.stream.flush()

Called when a test was expected to fail, but succeed.

Reimplemented from unittest.result.TestResult.

Definition at line 98 of file runner.py.

00098 
00099     def addUnexpectedSuccess(self, test):
00100         super(TextTestResult, self).addUnexpectedSuccess(test)
00101         if self.showAll:
00102             self.stream.writeln("unexpected success")
00103         elif self.dots:
00104             self.stream.write("u")
00105             self.stream.flush()

Definition at line 44 of file runner.py.

00044 
00045     def getDescription(self, test):
00046         doc_first_line = test.shortDescription()
00047         if self.descriptions and doc_first_line:
00048             return '\n'.join((str(test), doc_first_line))
00049         else:
00050             return str(test)

Here is the caller graph for this function:

def unittest.runner.TextTestResult.printErrorList (   self,
  flavour,
  errors 
)

Definition at line 112 of file runner.py.

00112 
00113     def printErrorList(self, flavour, errors):
00114         for test, err in errors:
00115             self.stream.writeln(self.separator1)
00116             self.stream.writeln("%s: %s" % (flavour,self.getDescription(test)))
00117             self.stream.writeln(self.separator2)
00118             self.stream.writeln("%s" % err)
00119 

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from unittest.result.TestResult.

Definition at line 106 of file runner.py.

00106 
00107     def printErrors(self):
00108         if self.dots or self.showAll:
00109             self.stream.writeln()
00110         self.printErrorList('ERROR', self.errors)
00111         self.printErrorList('FAIL', self.failures)

Here is the call graph for this function:

def unittest.runner.TextTestResult.startTest (   self,
  test 
)

Reimplemented from unittest.result.TestResult.

Definition at line 51 of file runner.py.

00051 
00052     def startTest(self, test):
00053         super(TextTestResult, self).startTest(test)
00054         if self.showAll:
00055             self.stream.write(self.getDescription(test))
00056             self.stream.write(" ... ")
00057             self.stream.flush()

Here is the call graph for this function:

def unittest.result.TestResult.startTestRun (   self) [inherited]
Called once before any tests are executed.

See startTest for a method called before each test.

Definition at line 72 of file result.py.

00072 
00073     def startTestRun(self):
00074         """Called once before any tests are executed.
00075 
00076         See startTest for a method called before each test.
00077         """

def unittest.result.TestResult.stop (   self) [inherited]

Definition at line 147 of file result.py.

00147 
00148     def stop(self):
00149         "Indicates that the tests should be aborted"
00150         self.shouldStop = True

def unittest.result.TestResult.stopTest (   self,
  test 
) [inherited]
Called when the given test has been run

Definition at line 78 of file result.py.

00078 
00079     def stopTest(self, test):
00080         """Called when the given test has been run"""
00081         self._restoreStdout()
00082         self._mirrorOutput = False

Here is the call graph for this function:

def unittest.result.TestResult.stopTestRun (   self) [inherited]
Called once after all tests are executed.

See stopTest for a method called after each test.

Definition at line 104 of file result.py.

00104 
00105     def stopTestRun(self):
00106         """Called once after all tests are executed.
00107 
00108         See stopTest for a method called after each test.
00109         """

def unittest.result.TestResult.wasSuccessful (   self) [inherited]

Definition at line 143 of file result.py.

00143 
00144     def wasSuccessful(self):
00145         "Tells whether or not this result was a success"
00146         return len(self.failures) == len(self.errors) == 0


Member Data Documentation

Definition at line 48 of file result.py.

Definition at line 42 of file runner.py.

Definition at line 41 of file runner.py.

Definition at line 42 of file result.py.

Definition at line 45 of file result.py.

Definition at line 40 of file result.py.

Definition at line 41 of file result.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.

Definition at line 34 of file runner.py.

Definition at line 35 of file runner.py.

Definition at line 47 of file result.py.

Definition at line 40 of file runner.py.

Definition at line 44 of file result.py.

Definition at line 39 of file runner.py.

Definition at line 43 of file result.py.

Definition at line 46 of file result.py.


The documentation for this class was generated from the following file: