[Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.20,
1.21
edloper at users.sourceforge.net
edloper at users.sourceforge.net
Tue Aug 17 18:37:45 CEST 2004
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24048/dist/src/Lib/test
Modified Files:
test_doctest.py
Log Message:
Fixed bug in line-number finding for examples (DocTestParser wasn't
updating line numbers correctly for bare prompts & examples containing
only comments).
Index: test_doctest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** test_doctest.py 12 Aug 2004 02:41:30 -0000 1.20
--- test_doctest.py 17 Aug 2004 16:37:12 -0000 1.21
***************
*** 254,258 ****
"""
- # [XX] test that it's getting line numbers right.
def test_DocTestFinder(): r"""
Unit tests for the `DocTestFinder` class.
--- 254,257 ----
***************
*** 451,454 ****
--- 450,477 ----
... print '%2s %s' % (len(t.examples), t.name)
1 SampleClass
+
+ Line numbers
+ ~~~~~~~~~~~~
+ DocTestFinder finds the line number of each example:
+
+ >>> def f(x):
+ ... '''
+ ... >>> x = 12
+ ...
+ ... some text
+ ...
+ ... >>> # examples are not created for comments & bare prompts.
+ ... >>>
+ ... ...
+ ...
+ ... >>> for x in range(10):
+ ... ... print x,
+ ... 0 1 2 3 4 5 6 7 8 9
+ ... >>> x/2
+ ... 6
+ ... '''
+ >>> test = doctest.DocTestFinder().find(f)[0]
+ >>> [e.lineno for e in test.examples]
+ [1, 9, 12]
"""
***************
*** 893,897 ****
**********************************************************************
Failure in example: print range(10) # doctest: -ELLIPSIS
! from line #6 of f
Expected: [0, 1, ..., 9]
Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
--- 916,920 ----
**********************************************************************
Failure in example: print range(10) # doctest: -ELLIPSIS
! from line #5 of f
Expected: [0, 1, ..., 9]
Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
More information about the Python-checkins
mailing list