mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Issue #19138: doctest's IGNORE_EXCEPTION_DETAIL now allows no detail at all.
(grafted from c80083ad142db2939507800c755082293a87f2de)
This commit is contained in:
parent
4b7f7acf30
commit
13e6d23bb1
3 changed files with 60 additions and 4 deletions
|
|
@ -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:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue