summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_doctest.py
diff options
context:
space:
mode:
authorTim Peters <tim@python.org>2013-12-04 03:02:05 (GMT)
committerTim Peters <tim@python.org>2013-12-04 03:02:05 (GMT)
commitf9a07f2e11c76c0c1ced04fed8b86c9d23cb3ac8 (patch)
tree76e591027897e4127ffe9754f4a37fb47176f99e /Lib/test/test_doctest.py
parent88c29877c7ebe04892d2800c4e554298b9e38465 (diff)
downloadcpython-f9a07f2e11c76c0c1ced04fed8b86c9d23cb3ac8.zip
cpython-f9a07f2e11c76c0c1ced04fed8b86c9d23cb3ac8.tar.gz
cpython-f9a07f2e11c76c0c1ced04fed8b86c9d23cb3ac8.tar.bz2
Issue #19138: doctest's IGNORE_EXCEPTION_DETAIL now allows no detail at all.
Diffstat (limited to 'Lib/test/test_doctest.py')
-rw-r--r--Lib/test/test_doctest.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index 5b53ca8..56193e8 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -1054,6 +1054,33 @@ But IGNORE_EXCEPTION_DETAIL does not allow a mismatch in the exception type:
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)
+
+Note that a trailing colon doesn't matter either:
+
+ >>> 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: