diff options
| author | Tim Peters <tim@python.org> | 2013-12-04 03:02:05 (GMT) |
|---|---|---|
| committer | Tim Peters <tim@python.org> | 2013-12-04 03:02:05 (GMT) |
| commit | 13e6d23bb13d481caa9e9491b85062b643668d22 (patch) | |
| tree | 19dff2bcc78ecb9efa0a0d564977ed9dd90a73bc /Lib/test/test_doctest.py | |
| parent | 4b7f7acf30991a8e4bcf61eba36cc695036703ca (diff) | |
| download | cpython-13e6d23bb13d481caa9e9491b85062b643668d22.zip cpython-13e6d23bb13d481caa9e9491b85062b643668d22.tar.gz cpython-13e6d23bb13d481caa9e9491b85062b643668d22.tar.bz2 | |
Issue #19138: doctest's IGNORE_EXCEPTION_DETAIL now allows no detail at all.
(grafted from c80083ad142db2939507800c755082293a87f2de)
Diffstat (limited to 'Lib/test/test_doctest.py')
| -rw-r--r-- | Lib/test/test_doctest.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py index 8f8c7c7..86259c3 100644 --- a/Lib/test/test_doctest.py +++ b/Lib/test/test_doctest.py @@ -1020,6 +1020,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: |
