Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
ac94f4f7
Commit
ac94f4f7
authored
Jun 01, 2010
by
R. David Murray
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#7583: clarify discussion of hard tab expansion in doctests.
parent
de535cb6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
10 deletions
+17
-10
Doc/library/doctest.rst
Doc/library/doctest.rst
+17
-10
No files found.
Doc/library/doctest.rst
View file @
ac94f4f7
...
...
@@ -299,15 +299,8 @@ their contained methods and nested classes.
How
are
Docstring
Examples
Recognized
?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In
most
cases
a
copy
-
and
-
paste
of
an
interactive
console
session
works
fine
,
but
doctest
isn
't trying to do an exact emulation of any specific Python shell. All
hard tab characters are expanded to spaces, using 8-column tab stops. If you
don'
t
believe
tabs
should
mean
that
,
too
bad
:
don
't use hard tabs, or write
your own :class:`DocTestParser` class.
.. versionchanged:: 2.4
Expanding tabs to spaces is new; previous versions tried to preserve hard tabs,
with confusing results.
In
most
cases
a
copy
-
and
-
paste
of
an
interactive
console
session
works
fine
,
but
doctest
isn
't trying to do an exact emulation of any specific Python shell.
::
...
...
@@ -342,6 +335,21 @@ The fine print:
``<BLANKLINE>`` was added; there was no way to use expected output containing
empty lines in previous versions.
* All hard tab characters are expanded to spaces, using 8-column tab stops.
Tabs in output generated by the tested code are not modified. Because any
hard tabs in the sample output *are* expanded, this means that if the code
output includes hard tabs, the only way the doctest can pass is if the
:const:`NORMALIZE_WHITESPACE` option or directive is in effect.
Alternatively, the test can be rewritten to capture the output and compare it
to an expected value as part of the test. This handling of tabs in the
source was arrived at through trial and error, and has proven to be the least
error prone way of handling them. It is possible to use a different
algorithm for handling tabs by writing a custom :class:`DocTestParser` class.
.. versionchanged:: 2.4
Expanding tabs to spaces is new; previous versions tried to preserve hard tabs,
with confusing results.
* Output to stdout is captured, but not output to stderr (exception tracebacks
are captured via a different means).
...
...
@@ -1872,4 +1880,3 @@ several options for organizing tests:
..
[#]
Examples
containing
both
expected
output
and
an
exception
are
not
supported
.
Trying
to
guess
where
one
ends
and
the
other
begins
is
too
error
-
prone
,
and
that
also
makes
for
a
confusing
test
.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment