diff -r 8e180b2067e4 Lib/doctest.py --- a/Lib/doctest.py Mon Sep 30 22:29:48 2013 +0200 +++ b/Lib/doctest.py Tue Oct 01 11:37:38 2013 -0400 @@ -1324,8 +1324,8 @@ # Another chance if they didn't care about the detail. elif self.optionflags & IGNORE_EXCEPTION_DETAIL: - m1 = re.match(r'(?:[^:]*\.)?([^:]*:)', example.exc_msg) - m2 = re.match(r'(?:[^:]*\.)?([^:]*:)', exc_msg) + 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 diff -r 8e180b2067e4 Lib/test/test_doctest.py --- a/Lib/test/test_doctest.py Mon Sep 30 22:29:48 2013 +0200 +++ b/Lib/test/test_doctest.py Tue Oct 01 11:37:38 2013 -0400 @@ -1020,6 +1020,20 @@ ValueError: message TestResults(failed=1, attempted=1) +If the exception does not have a message, you can still use +IGNORE_EXCEPTION_DETAIL to normalize the modules between Python 2 and 3. + + >>> 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=False).run(test) + TestResults(failed=0, attempted=2) + If an exception is raised but not expected, then it is reported as an unexpected exception: