summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_doctest.py
diff options
context:
space:
mode:
authorEdward Loper <edloper@gradient.cis.upenn.edu>2004-08-25 23:07:03 (GMT)
committerEdward Loper <edloper@gradient.cis.upenn.edu>2004-08-25 23:07:03 (GMT)
commit19b1958730f290ad6bf309653d76f222906f0c41 (patch)
treec55dcc59d2602f07eec240a998fd433353434831 /Lib/test/test_doctest.py
parentd2afee47b13854c265a5fb8eb5a53daf7b27ecf9 (diff)
downloadcpython-19b1958730f290ad6bf309653d76f222906f0c41.zip
cpython-19b1958730f290ad6bf309653d76f222906f0c41.tar.gz
cpython-19b1958730f290ad6bf309653d76f222906f0c41.tar.bz2
Only recognize the expected output as an exception if it *starts* with
a traceback message. I.e., examples that raise exceptions may no longer generate pre-exception output. This restores the behavior of doctest in python 2.3. The ability to check pre-exception output is being removed because it makes the documentation simpler; and because there are very few use cases for it.
Diffstat (limited to 'Lib/test/test_doctest.py')
-rw-r--r--Lib/test/test_doctest.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index d5e9ef5..5d0cf90 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -623,8 +623,10 @@ replaced with any other string:
>>> doctest.DocTestRunner(verbose=False).run(test)
(0, 2)
-An example may generate output before it raises an exception; if it
-does, then the output must match the expected output:
+An example may not generate output before it raises an exception; if
+it does, then the traceback message will not be recognized as
+signaling an expected exception, so the example will be reported as an
+unexpected exception:
>>> def f(x):
... '''
@@ -636,7 +638,15 @@ does, then the output must match the expected output:
... '''
>>> test = doctest.DocTestFinder().find(f)[0]
>>> doctest.DocTestRunner(verbose=False).run(test)
- (0, 2)
+ ... # doctest: +ELLIPSIS
+ **********************************************************************
+ Line 3, in f
+ Failed example:
+ print 'pre-exception output', x/0
+ Exception raised:
+ ...
+ ZeroDivisionError: integer division or modulo by zero
+ (1, 2)
Exception messages may contain newlines: