Back to index

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

List of all members.

Public Member Functions

def run
def report_unexpected_exception
def report_failure
def report_start
def report_success
def summarize
def merge

Public Attributes

 optionflags
 original_optionflags
 tries
 failures
 test
 debugger
 save_linecache_getlines

Static Public Attributes

string DIVIDER = "*"

Detailed Description

Definition at line 1666 of file doctest.py.


Member Function Documentation

def doctest.DocTestRunner.merge (   self,
  other 
) [inherited]

Definition at line 1467 of file doctest.py.

01467 
01468     def merge(self, other):
01469         d = self._name2ft
01470         for name, (f, t) in other._name2ft.items():
01471             if name in d:
01472                 # Don't print here by default, since doing
01473                 #     so breaks some of the buildbots
01474                 #print("*** DocTestRunner.merge: '" + name + "' in both" \
01475                 #    " testers; summing outcomes.")
01476                 f2, t2 = d[name]
01477                 f = f + f2
01478                 t = t + t2
01479             d[name] = f, t

def doctest.DebugRunner.report_failure (   self,
  out,
  test,
  example,
  got 
)
Report that the given example failed.

Reimplemented from doctest.DocTestRunner.

Definition at line 1766 of file doctest.py.

01766 
01767     def report_failure(self, out, test, example, got):
01768         raise DocTestFailure(test, example, got)

def doctest.DocTestRunner.report_start (   self,
  out,
  test,
  example 
) [inherited]
Report that the test runner is about to process the given
example.  (Only displays a message if verbose=True)

Definition at line 1140 of file doctest.py.

01140 
01141     def report_start(self, out, test, example):
01142         """
01143         Report that the test runner is about to process the given
01144         example.  (Only displays a message if verbose=True)
01145         """
01146         if self._verbose:
01147             if example.want:
01148                 out('Trying:\n' + _indent(example.source) +
01149                     'Expecting:\n' + _indent(example.want))
01150             else:
01151                 out('Trying:\n' + _indent(example.source) +
01152                     'Expecting nothing\n')

Here is the call graph for this function:

Here is the caller graph for this function:

def doctest.DocTestRunner.report_success (   self,
  out,
  test,
  example,
  got 
) [inherited]
Report that the given example ran successfully.  (Only
displays a message if verbose=True)

Definition at line 1153 of file doctest.py.

01153 
01154     def report_success(self, out, test, example, got):
01155         """
01156         Report that the given example ran successfully.  (Only
01157         displays a message if verbose=True)
01158         """
01159         if self._verbose:
01160             out("ok\n")

Here is the caller graph for this function:

def doctest.DebugRunner.report_unexpected_exception (   self,
  out,
  test,
  example,
  exc_info 
)
Report that the given example raised an unexpected exception.

Reimplemented from doctest.DocTestRunner.

Definition at line 1763 of file doctest.py.

01763 
01764     def report_unexpected_exception(self, out, test, example, exc_info):
01765         raise UnexpectedException(test, example, exc_info)

def doctest.DebugRunner.run (   self,
  test,
  compileflags = None,
  out = None,
  clear_globs = True 
)
Run the examples in `test`, and display the results using the
writer function `out`.

The examples are run in the namespace `test.globs`.  If
`clear_globs` is true (the default), then this namespace will
be cleared after the test runs, to help with garbage
collection.  If you would like to examine the namespace after
the test completes, then use `clear_globs=False`.

`compileflags` gives the set of flags that should be used by
the Python compiler when running the examples.  If not
specified, then it will default to the set of future-import
flags that apply to `globs`.

The output of each example is checked using
`DocTestRunner.check_output`, and the results are formatted by
the `DocTestRunner.report_*` methods.

Reimplemented from doctest.DocTestRunner.

Definition at line 1757 of file doctest.py.

01757 
01758     def run(self, test, compileflags=None, out=None, clear_globs=True):
01759         r = DocTestRunner.run(self, test, compileflags, out, False)
01760         if clear_globs:
01761             test.globs.clear()
01762         return r

Here is the caller graph for this function:

def doctest.DocTestRunner.summarize (   self,
  verbose = None 
) [inherited]
Print a summary of all the test cases that have been run by
this DocTestRunner, and return a tuple `(f, t)`, where `f` is
the total number of failed examples, and `t` is the total
number of tried examples.

The optional `verbose` argument controls how detailed the
summary is.  If the verbosity is not specified, then the
DocTestRunner's verbosity is used.

Definition at line 1410 of file doctest.py.

01410 
01411     def summarize(self, verbose=None):
01412         """
01413         Print a summary of all the test cases that have been run by
01414         this DocTestRunner, and return a tuple `(f, t)`, where `f` is
01415         the total number of failed examples, and `t` is the total
01416         number of tried examples.
01417 
01418         The optional `verbose` argument controls how detailed the
01419         summary is.  If the verbosity is not specified, then the
01420         DocTestRunner's verbosity is used.
01421         """
01422         if verbose is None:
01423             verbose = self._verbose
01424         notests = []
01425         passed = []
01426         failed = []
01427         totalt = totalf = 0
01428         for x in self._name2ft.items():
01429             name, (f, t) = x
01430             assert f <= t
01431             totalt += t
01432             totalf += f
01433             if t == 0:
01434                 notests.append(name)
01435             elif f == 0:
01436                 passed.append( (name, t) )
01437             else:
01438                 failed.append(x)
01439         if verbose:
01440             if notests:
01441                 print(len(notests), "items had no tests:")
01442                 notests.sort()
01443                 for thing in notests:
01444                     print("   ", thing)
01445             if passed:
01446                 print(len(passed), "items passed all tests:")
01447                 passed.sort()
01448                 for thing, count in passed:
01449                     print(" %3d tests in %s" % (count, thing))
01450         if failed:
01451             print(self.DIVIDER)
01452             print(len(failed), "items had failures:")
01453             failed.sort()
01454             for thing, (f, t) in failed:
01455                 print(" %3d of %3d in %s" % (f, t, thing))
01456         if verbose:
01457             print(totalt, "tests in", len(self._name2ft), "items.")
01458             print(totalt - totalf, "passed and", totalf, "failed.")
01459         if totalf:
01460             print("***Test Failed***", totalf, "failures.")
01461         elif verbose:
01462             print("Test passed.")
01463         return TestResults(totalf, totalt)


Member Data Documentation

Definition at line 1382 of file doctest.py.

string doctest.DocTestRunner.DIVIDER = "*" [static, inherited]

Definition at line 1102 of file doctest.py.

Definition at line 1130 of file doctest.py.

Definition at line 1125 of file doctest.py.

Definition at line 1126 of file doctest.py.

Definition at line 1388 of file doctest.py.

Definition at line 1359 of file doctest.py.

Definition at line 1129 of file doctest.py.


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