Orbits  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
Public Member Functions | Private Member Functions | Static Private Attributes | List of all members
setuptools.tests.doctest.DocTestParser Class Reference

Public Member Functions

def parse
 
def get_doctest
 
def get_examples
 

Private Member Functions

def _parse_example
 

Static Private Attributes

tuple _EXAMPLE_RE
 
tuple _EXCEPTION_RE = re.compile(r""" # Grab the traceback header. Different versions of Python have # said different things on the first traceback line. ^(?P<hdr> Traceback\ \( (?: most\ recent\ call\ last | innermost\ last ) \) : ) \s* $ # toss trailing whitespace on the header. (?P<stack> .*?) # don't blink: absorb stuff until... ^ (?P<msg> \w+ .*) # a line *starts* with alphanum. """, re.VERBOSE | re.MULTILINE | re.DOTALL)
 
tuple _IS_BLANK_OR_COMMENT = re.compile(r'^[ ]*(#.*)?$')
 

Detailed Description

  1. DocTestParser
    A class used to parse strings containing doctest examples.
    

Member Function Documentation

def setuptools.tests.doctest.DocTestParser._parse_example (   self,
  m,
  name,
  lineno 
)
private
Given a regular expression match from `_EXAMPLE_RE` (`m`),
return a pair `(source, want)`, where `source` is the matched
example's source code (with prompts and indentation stripped);
and `want` is the example's expected output (with indentation
stripped).

`name` is the string's name, and `lineno` is the line number
where the example starts; both are used for error messages.
def setuptools.tests.doctest.DocTestParser.get_doctest (   self,
  string,
  globs,
  name,
  filename,
  lineno 
)
Extract all doctest examples from the given string, and
collect them into a `DocTest` object.

`globs`, `name`, `filename`, and `lineno` are attributes for
the new `DocTest` object.  See the documentation for `DocTest`
for more information.
def setuptools.tests.doctest.DocTestParser.get_examples (   self,
  string,
  name = '<string>' 
)
Extract all doctest examples from the given string, and return
them as a list of `Example` objects.  Line numbers are
0-based, because it's most common in doctests that nothing
interesting appears on the same line as opening triple-quote,
and so the first interesting line is called \"line 1\" then.

The optional argument `name` is a name identifying this
string, and is only used for error messages.
def setuptools.tests.doctest.DocTestParser.parse (   self,
  string,
  name = '<string>' 
)
Divide the given string into examples and intervening text,
and return them as a list of alternating Examples and strings.
Line numbers for the Examples are 0-based.  The optional
argument `name` is a name identifying this string, and is only
used for error messages.

Member Data Documentation

tuple setuptools.tests.doctest.DocTestParser._EXAMPLE_RE
staticprivate
Initial value:
1 = re.compile(r'''
2  # Source consists of a PS1 line followed by zero or more PS2 lines.
3  (?P<source>
4  (?:^(?P<indent> [ ]*) >>> .*) # PS1 line
5  (?:\n [ ]* \.\.\. .*)*) # PS2 lines
6  \n?
7  # Want consists of any non-blank lines that do not start with PS1.
8  (?P<want> (?:(?![ ]*$) # Not a blank line
9  (?![ ]*>>>) # Not a line starting with PS1
10  .*$\n? # But any other line
11  )*)
12  ''', re.MULTILINE | re.VERBOSE)
tuple setuptools.tests.doctest.DocTestParser._EXCEPTION_RE = re.compile(r""" # Grab the traceback header. Different versions of Python have # said different things on the first traceback line. ^(?P<hdr> Traceback\ \( (?: most\ recent\ call\ last | innermost\ last ) \) : ) \s* $ # toss trailing whitespace on the header. (?P<stack> .*?) # don't blink: absorb stuff until... ^ (?P<msg> \w+ .*) # a line *starts* with alphanum. """, re.VERBOSE | re.MULTILINE | re.DOTALL)
staticprivate
tuple setuptools.tests.doctest.DocTestParser._IS_BLANK_OR_COMMENT = re.compile(r'^[ ]*(#.*)?$')
staticprivate

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

Copyright 2014 Google Inc. All rights reserved.