Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
doctest.DocTest Class Reference

List of all members.

Public Member Functions

def __init__
def __repr__
def __lt__

Public Attributes

 examples
 docstring
 globs
 name
 filename
 lineno

Detailed Description

A collection of doctest examples that should be run in a single
namespace.  Each `DocTest` defines the following attributes:

  - examples: the list of examples.

  - globs: The namespace (aka globals) that the examples should
    be run in.

  - name: A name identifying the DocTest (typically, the name of
    the object whose docstring this DocTest was extracted from).

  - filename: The name of the file that this DocTest was extracted
    from, or `None` if the filename is unknown.

  - lineno: The line number within filename where this DocTest
    begins, or `None` if the line number is unavailable.  This
    line number is zero-based, with respect to the beginning of
    the file.

  - docstring: The string that the examples were extracted from,
    or `None` if the string is unavailable.

Definition at line 443 of file doctest.py.


Constructor & Destructor Documentation

def doctest.DocTest.__init__ (   self,
  examples,
  globs,
  name,
  filename,
  lineno,
  docstring 
)
Create a new DocTest containing the given examples.  The
DocTest's globals are initialized with a copy of `globs`.

Definition at line 467 of file doctest.py.

00467 
00468     def __init__(self, examples, globs, name, filename, lineno, docstring):
00469         """
00470         Create a new DocTest containing the given examples.  The
00471         DocTest's globals are initialized with a copy of `globs`.
00472         """
00473         assert not isinstance(examples, str), \
00474                "DocTest no longer accepts str; use DocTestParser instead"
00475         self.examples = examples
00476         self.docstring = docstring
00477         self.globs = globs.copy()
00478         self.name = name
00479         self.filename = filename
00480         self.lineno = lineno

Here is the caller graph for this function:


Member Function Documentation

def doctest.DocTest.__lt__ (   self,
  other 
)

Definition at line 493 of file doctest.py.

00493 
00494     def __lt__(self, other):
00495         if not isinstance(other, DocTest):
00496             return NotImplemented
00497         return ((self.name, self.filename, self.lineno, id(self))
00498                 <
00499                 (other.name, other.filename, other.lineno, id(other)))

def doctest.DocTest.__repr__ (   self)

Definition at line 481 of file doctest.py.

00481 
00482     def __repr__(self):
00483         if len(self.examples) == 0:
00484             examples = 'no examples'
00485         elif len(self.examples) == 1:
00486             examples = '1 example'
00487         else:
00488             examples = '%d examples' % len(self.examples)
00489         return ('<DocTest %s from %s:%s (%s)>' %
00490                 (self.name, self.filename, self.lineno, examples))
00491 


Member Data Documentation

Definition at line 475 of file doctest.py.

Definition at line 474 of file doctest.py.

Definition at line 478 of file doctest.py.

Definition at line 476 of file doctest.py.

Definition at line 479 of file doctest.py.

Definition at line 477 of file doctest.py.


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