Message198792
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(m1.group(1), m2.group(1), self.optionflags): 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 http://bugs.python.org/issue7490 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. Example:: >>> def f(x): ... r''' ... >>> from http.client import HTTPException ... >>> raise HTTPException() #doctest: +IGNORE_EXCEPTION_DETAIL ... Traceback (most recent call last): ... foo.bar.HTTPException ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=True).run(test) Failed example: raise HTTPException() #doctest: +IGNORE_EXCEPTION_DETAIL Expected: Traceback (most recent call last): foo.bar.HTTPException Got: Traceback (most recent call last): ... http.client.HTTPException I've attached a test and a very naive fix of the regular expression. | |
| Date | User | Action | Args | | 2013-10-01 15:54:51 | jamur2 | set | recipients: + jamur2 | | 2013-10-01 15:54:51 | jamur2 | set | messageid: <1380642891.76.0.189533758192.issue19138@psf.upfronthosting.co.za> | | 2013-10-01 15:54:51 | jamur2 | link | issue19138 messages | | 2013-10-01 15:54:51 | jamur2 | create | | |