Back to index

python3.2  3.2.2
Public Member Functions
doctest.SkipDocTestCase Class Reference
Inheritance diagram for doctest.SkipDocTestCase:
Inheritance graph
[legend]
Collaboration diagram for doctest.SkipDocTestCase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def setUp
def test_skip
def shortDescription
def tearDown
def runTest
def format_failure
def debug
def id
def __repr__

Detailed Description

Definition at line 2216 of file doctest.py.


Constructor & Destructor Documentation

Definition at line 2217 of file doctest.py.

02217 
02218     def __init__(self):
02219         DocTestCase.__init__(self, None)

Here is the caller graph for this function:


Member Function Documentation

def doctest.DocTestCase.__repr__ (   self) [inherited]

Reimplemented in doctest.DocFileCase.

Definition at line 2207 of file doctest.py.

02207 
02208     def __repr__(self):
02209         name = self._dt_test.name.split('.')
02210         return "%s (%s)" % (name[-1], '.'.join(name[:-1]))

def doctest.DocTestCase.debug (   self) [inherited]

Definition at line 2132 of file doctest.py.

02132 
02133     def debug(self):
02134         r"""Run the test case without results and without catching exceptions
02135 
02136            The unit test framework includes a debug method on test cases
02137            and test suites to support post-mortem debugging.  The test code
02138            is run in such a way that errors are not caught.  This way a
02139            caller can catch the errors and initiate post-mortem debugging.
02140 
02141            The DocTestCase provides a debug method that raises
02142            UnexpectedException errors if there is an unexpected
02143            exception:
02144 
02145              >>> test = DocTestParser().get_doctest('>>> raise KeyError\n42',
02146              ...                {}, 'foo', 'foo.py', 0)
02147              >>> case = DocTestCase(test)
02148              >>> try:
02149              ...     case.debug()
02150              ... except UnexpectedException as f:
02151              ...     failure = f
02152 
02153            The UnexpectedException contains the test, the example, and
02154            the original exception:
02155 
02156              >>> failure.test is test
02157              True
02158 
02159              >>> failure.example.want
02160              '42\n'
02161 
02162              >>> exc_info = failure.exc_info
02163              >>> raise exc_info[1] # Already has the traceback
02164              Traceback (most recent call last):
02165              ...
02166              KeyError
02167 
02168            If the output doesn't match, then a DocTestFailure is raised:
02169 
02170              >>> test = DocTestParser().get_doctest('''
02171              ...      >>> x = 1
02172              ...      >>> x
02173              ...      2
02174              ...      ''', {}, 'foo', 'foo.py', 0)
02175              >>> case = DocTestCase(test)
02176 
02177              >>> try:
02178              ...    case.debug()
02179              ... except DocTestFailure as f:
02180              ...    failure = f
02181 
02182            DocTestFailure objects provide access to the test:
02183 
02184              >>> failure.test is test
02185              True
02186 
02187            As well as to the example:
02188 
02189              >>> failure.example.want
02190              '2\n'
02191 
02192            and the actual output:
02193 
02194              >>> failure.got
02195              '1\n'
02196 
02197            """
02198 
02199         self.setUp()
02200         runner = DebugRunner(optionflags=self._dt_optionflags,
02201                              checker=self._dt_checker, verbose=False)
02202         runner.run(self._dt_test, clear_globs=False)
02203         self.tearDown()

Here is the caller graph for this function:

def doctest.DocTestCase.format_failure (   self,
  err 
) [inherited]

Reimplemented in doctest.DocFileCase.

Definition at line 2120 of file doctest.py.

02120 
02121     def format_failure(self, err):
02122         test = self._dt_test
02123         if test.lineno is None:
02124             lineno = 'unknown line number'
02125         else:
02126             lineno = '%s' % test.lineno
02127         lname = '.'.join(test.name.split('.')[-1:])
02128         return ('Failed doctest test for %s\n'
02129                 '  File "%s", line %s, in %s\n\n%s'
02130                 % (test.name, test.filename, lineno, lname, err)
02131                 )

Here is the caller graph for this function:

def doctest.DocTestCase.id (   self) [inherited]

Reimplemented in doctest.DocFileCase.

Definition at line 2204 of file doctest.py.

02204 
02205     def id(self):
02206         return self._dt_test.name

Here is the caller graph for this function:

def doctest.DocTestCase.runTest (   self) [inherited]

Definition at line 2096 of file doctest.py.

02096 
02097     def runTest(self):
02098         test = self._dt_test
02099         old = sys.stdout
02100         new = StringIO()
02101         optionflags = self._dt_optionflags
02102 
02103         if not (optionflags & REPORTING_FLAGS):
02104             # The option flags don't include any reporting flags,
02105             # so add the default reporting flags
02106             optionflags |= _unittest_reportflags
02107 
02108         runner = DocTestRunner(optionflags=optionflags,
02109                                checker=self._dt_checker, verbose=False)
02110 
02111         try:
02112             runner.DIVIDER = "-"*70
02113             failures, tries = runner.run(
02114                 test, out=new.write, clear_globs=False)
02115         finally:
02116             sys.stdout = old
02117 
02118         if failures:
02119             raise self.failureException(self.format_failure(new.getvalue()))

Here is the call graph for this function:

Reimplemented from doctest.DocTestCase.

Definition at line 2220 of file doctest.py.

02220 
02221     def setUp(self):
02222         self.skipTest("DocTestSuite will not work with -O2 and above")

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from doctest.DocTestCase.

Definition at line 2226 of file doctest.py.

02226 
02227     def shortDescription(self):
02228         return "Skipping tests from %s" % module.__name__

Here is the caller graph for this function:

def doctest.DocTestCase.tearDown (   self) [inherited]

Definition at line 2088 of file doctest.py.

02088 
02089     def tearDown(self):
02090         test = self._dt_test
02091 
02092         if self._dt_tearDown is not None:
02093             self._dt_tearDown(test)
02094 
02095         test.globs.clear()

Here is the caller graph for this function:

Definition at line 2223 of file doctest.py.

02223 
02224     def test_skip(self):
02225         pass


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