[Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.29, 1.30

edloper at users.sourceforge.net edloper at users.sourceforge.net
Thu Aug 26 01:07:05 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23763/dist/src/Lib/test
Modified Files:
	test_doctest.py 
Log Message:
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.
Index: test_doctest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- test_doctest.py	23 Aug 2004 22:38:05 -0000	1.29
+++ test_doctest.py	25 Aug 2004 23:07:03 -0000	1.30
@@ -623,8 +623,10 @@
 >>> 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 @@
 ... '''
 >>> 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:
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /