Back to index

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

List of all members.

Public Member Functions

def __init__
def run

Public Attributes

 stream
 descriptions
 verbosity
 failfast
 buffer
 warnings
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Static Public Attributes

 resultclass = TextTestResult

Private Member Functions

def _makeResult

Detailed Description

A test runner class that displays results in textual form.

It prints out the names of tests as they are run, errors as they
occur, and a summary of the results at the end of the test run.

Definition at line 120 of file runner.py.


Constructor & Destructor Documentation

def unittest.runner.TextTestRunner.__init__ (   self,
  stream = None,
  descriptions = True,
  verbosity = 1,
  failfast = False,
  buffer = False,
  resultclass = None,
  warnings = None 
)

Definition at line 129 of file runner.py.

00129 
00130                  failfast=False, buffer=False, resultclass=None, warnings=None):
00131         if stream is None:
00132             stream = sys.stderr
00133         self.stream = _WritelnDecorator(stream)
00134         self.descriptions = descriptions
00135         self.verbosity = verbosity
00136         self.failfast = failfast
00137         self.buffer = buffer
00138         self.warnings = warnings
00139         if resultclass is not None:
00140             self.resultclass = resultclass

Here is the caller graph for this function:


Member Function Documentation

Definition at line 141 of file runner.py.

00141 
00142     def _makeResult(self):
00143         return self.resultclass(self.stream, self.descriptions, self.verbosity)

Here is the caller graph for this function:

def unittest.runner.TextTestRunner.run (   self,
  test 
)

Definition at line 144 of file runner.py.

00144 
00145     def run(self, test):
00146         "Run the given test case or test suite."
00147         result = self._makeResult()
00148         registerResult(result)
00149         result.failfast = self.failfast
00150         result.buffer = self.buffer
00151         with warnings.catch_warnings():
00152             if self.warnings:
00153                 # if self.warnings is set, use it to filter all the warnings
00154                 warnings.simplefilter(self.warnings)
00155                 # if the filter is 'default' or 'always', special-case the
00156                 # warnings from the deprecated unittest methods to show them
00157                 # no more than once per module, because they can be fairly
00158                 # noisy.  The -Wd and -Wa flags can be used to bypass this
00159                 # only when self.warnings is None.
00160                 if self.warnings in ['default', 'always']:
00161                     warnings.filterwarnings('module',
00162                             category=DeprecationWarning,
00163                             message='Please use assert\w+ instead.')
00164             startTime = time.time()
00165             startTestRun = getattr(result, 'startTestRun', None)
00166             if startTestRun is not None:
00167                 startTestRun()
00168             try:
00169                 test(result)
00170             finally:
00171                 stopTestRun = getattr(result, 'stopTestRun', None)
00172                 if stopTestRun is not None:
00173                     stopTestRun()
00174             stopTime = time.time()
00175         timeTaken = stopTime - startTime
00176         result.printErrors()
00177         if hasattr(result, 'separator2'):
00178             self.stream.writeln(result.separator2)
00179         run = result.testsRun
00180         self.stream.writeln("Ran %d test%s in %.3fs" %
00181                             (run, run != 1 and "s" or "", timeTaken))
00182         self.stream.writeln()
00183 
00184         expectedFails = unexpectedSuccesses = skipped = 0
00185         try:
00186             results = map(len, (result.expectedFailures,
00187                                 result.unexpectedSuccesses,
00188                                 result.skipped))
00189         except AttributeError:
00190             pass
00191         else:
00192             expectedFails, unexpectedSuccesses, skipped = results
00193 
00194         infos = []
00195         if not result.wasSuccessful():
00196             self.stream.write("FAILED")
00197             failed, errored = len(result.failures), len(result.errors)
00198             if failed:
00199                 infos.append("failures=%d" % failed)
00200             if errored:
00201                 infos.append("errors=%d" % errored)
00202         else:
00203             self.stream.write("OK")
00204         if skipped:
00205             infos.append("skipped=%d" % skipped)
00206         if expectedFails:
00207             infos.append("expected failures=%d" % expectedFails)
00208         if unexpectedSuccesses:
00209             infos.append("unexpected successes=%d" % unexpectedSuccesses)
00210         if infos:
00211             self.stream.writeln(" (%s)" % (", ".join(infos),))
00212         else:
00213             self.stream.write("\n")
00214         return result

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 136 of file runner.py.

Definition at line 133 of file runner.py.

Definition at line 135 of file runner.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 126 of file runner.py.

Definition at line 132 of file runner.py.

Definition at line 134 of file runner.py.

Definition at line 137 of file runner.py.


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