mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Rewrote Parser, using regular expressions instead of walking though
the string one line at a time. The resulting code is (in my opinion, anyway), much easier to read. In the process, I found and fixed a bug in the orginal parser's line numbering in error messages (it was inconsistant between 0-based and 1-based). Also, check for missing blank lines after the prompt on all prompt lines, not just PS1 lines (test added).
This commit is contained in:
parent
103d26e851
commit
7c748469c7
2 changed files with 227 additions and 221 deletions
|
@ -209,7 +209,7 @@ expected output of an example, then `DocTest` will raise a ValueError:
|
|||
... '''
|
||||
>>> doctest.DocTest(docstring, globs, 'some_test', 'filename', 0)
|
||||
Traceback (most recent call last):
|
||||
ValueError: line 3 of the docstring for some_test has inconsistent leading whitespace: ' indentation'
|
||||
ValueError: line 4 of the docstring for some_test has inconsistent leading whitespace: ' indentation'
|
||||
|
||||
If the docstring contains inconsistent leading whitespace on
|
||||
continuation lines, then `DocTest` will raise a ValueError:
|
||||
|
@ -229,7 +229,16 @@ will raise a ValueError:
|
|||
>>> docstring = '>>>print 1\n1'
|
||||
>>> doctest.DocTest(docstring, globs, 'some_test', 'filename', 0)
|
||||
Traceback (most recent call last):
|
||||
ValueError: line 0 of the docstring for some_test lacks blank after >>>: '>>>print 1'
|
||||
ValueError: line 1 of the docstring for some_test lacks blank after >>>: '>>>print 1'
|
||||
|
||||
If there's no blank space after a PS2 prompt ('...'), then `DocTest`
|
||||
will raise a ValueError:
|
||||
|
||||
>>> docstring = '>>> if 1:\n...print 1\n1'
|
||||
>>> doctest.DocTest(docstring, globs, 'some_test', 'filename', 0)
|
||||
Traceback (most recent call last):
|
||||
ValueError: line 2 of the docstring for some_test lacks blank after ...: '...print 1'
|
||||
|
||||
"""
|
||||
|
||||
# [XX] test that it's getting line numbers right.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue