diff options
author | Edward Loper <edloper@gradient.cis.upenn.edu> | 2004-09-30 17:18:18 (GMT) |
---|---|---|
committer | Edward Loper <edloper@gradient.cis.upenn.edu> | 2004-09-30 17:18:18 (GMT) |
commit | 0fe00aafc3a40c6979980fd6b713e79b2f5b722f (patch) | |
tree | 44f6fae501b240202ff7056648674d920af2dc29 /Doc | |
parent | 49c522be80c075c7cb4ccabb897cf9043e938181 (diff) | |
download | cpython-0fe00aafc3a40c6979980fd6b713e79b2f5b722f.zip cpython-0fe00aafc3a40c6979980fd6b713e79b2f5b722f.tar.gz cpython-0fe00aafc3a40c6979980fd6b713e79b2f5b722f.tar.bz2 |
Added 2 notes about the complexities of testing SyntaxErrors.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/lib/libdoctest.tex | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Doc/lib/libdoctest.tex b/Doc/lib/libdoctest.tex index 2635486..92aa039 100644 --- a/Doc/lib/libdoctest.tex +++ b/Doc/lib/libdoctest.tex @@ -495,6 +495,37 @@ Some details you should read once, but won't need to remember: \item When the \constant{IGNORE_EXCEPTION_DETAIL} doctest option is is specified, everything following the leftmost colon is ignored. +\item The interactive shell omits the traceback header line for some + \exception{SyntaxError}s. But doctest uses the traceback header + line to distinguish exceptions from non-exceptions. So in the rare + case where you need to test a \exception{SyntaxError} that omits the + traceback header, you will need to manually add the traceback header + line to your test example. + +\item For some \exception{SyntaxError}s, Python displays the character + position of the syntax error, using a \code{\^} marker: + +\begin{verbatim} +>>> 1 1 + File "<stdin>", line 1 + 1 1 + ^ +SyntaxError: invalid syntax +\end{verbatim} + + Since the lines showing the position of the error come before the + exception type and detail, they are not checked by doctest. For + example, the following test would pass, even though it puts the + \code{\^} marker in the wrong location: + +\begin{verbatim} +>>> 1 1 + File "<stdin>", line 1 + 1 1 + ^ +SyntaxError: invalid syntax +\end{verbatim} + \end{itemize} \versionchanged[The ability to handle a multi-line exception detail, |