I am trying to run the following docstring using docutils.DocTes tSuite:
"""
s = "a\n \t\n\t\t \t\nb"
etc...
"""
However, docutils complains about "inconsiste nt leading whitespace". Well,
that's not the problem.
I inserted traces in various places in Lib/Python23/doctest.py. This is
what I found:
1. Tester._get_doc test returns __doc__, and in this case repr(__doc__) is:
' >>> s = "a\n \t\n\t\t \t\nb"\n etc...'
So you can see the problem: all newlines (all the '\n' characters) are equal
here, whether or not they are inside strings!
Note: this came from a an actual dump: I hope it has survived the cut/paste
relatively intact.
2. Naturally, doctest._extrac t_examples(s) complains because it thinks the
lines in s are improperly indented.
Indeed, doctest._extrac t_examples contains the following code:
lines = s.split("\n")
i, n = 0, len(lines)
while i < n:
.....line = lines[i]
.....<< do something with line i >>
Printing "EKR:", repr(line) in this code yields:
EKR: ' >>> s = "a'
EKR: ' \t'
EKR: '\t\t \t'
EKR: 'b"'
This should make it perfectly clear what is happening and why
doctest._extrac t_examples complains about indentation.
Is this a bug? If so, is there a workaround? If this isn't a bug, why not?
I don't see anything in the doctest docs about this kind of problem. Am I
doing something obviously wrong?
Thanks,
Edward
--------------------------------------------------------------------
Edward K. Ream email: ed*******@chart er.net
Leo: Literate Editor with Outlines
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------