Author jamur2
Recipients jamur2
Date 2013-10-01.15:54:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The doctest.IGNORE_EXCEPTION_DETAIL optionflag does not seem to have the
desired behavior when the exception does not provide a message, due to the
regular expressions in doctest.DocTestRunner.__run expecting a colon in the
second group::

                elif self.optionflags & IGNORE_EXCEPTION_DETAIL:
                    m1 = re.match(r'(?:[^:]*\.)?([^:]*:)', example.exc_msg)
                    m2 = re.match(r'(?:[^:]*\.)?([^:]*:)', exc_msg)
                    if m1 and m2 and check(,,
                        outcome = SUCCESS

Normally this wouldn't matter, as there's no need to ignore the exception
detail if there is no detail to normalize, but since it looks like the blessed method of
normalizing Python 2 and 3 exceptions in doctests is to use
IGNORE_EXCEPTION_DETAIL.  This doesn't work for any exceptions which do
not have a message.


    >>> def f(x):
    ...     r'''
    ...     >>> from http.client import HTTPException
    ...     >>> raise HTTPException() #doctest: +IGNORE_EXCEPTION_DETAIL
    ...     Traceback (most recent call last):
    ...     '''
    >>> test = doctest.DocTestFinder().find(f)[0]
    >>> doctest.DocTestRunner(verbose=True).run(test)
    Failed example:
        raise HTTPException() #doctest: +IGNORE_EXCEPTION_DETAIL
        Traceback (most recent call last):
        Traceback (most recent call last):

I've attached a test and a very naive fix of the regular expression.
Date User Action Args
2013-10-01 15:54:51jamur2setrecipients: + jamur2
2013-10-01 15:54:51jamur2setmessageid: <>
2013-10-01 15:54:51jamur2linkissue19138 messages
2013-10-01 15:54:51jamur2create