Re: [Python-Dev] doctest improvements
Tim Peters wrote:
[...] Making a doctest reader learn a special "doctest markup language" is A Problem in this case. Offhand, I'd be happier with an almost-self-evident (say)
<blank line>
Perhaps you'd be happier with a different value of BLANKLINE_MARKER, then? E.g. "blank>": def test(): r""" A different marker: >>> print 'a\n\nb' a blank> b """ Although this means that you have to indent the doctest quite far. Perhaps it would be better if I changed the patch so the marker doesn't need to dedented all the way? E.g.: def test(): r""" A different marker: >>> print 'a\n\nb' a <blank line> b """ Another option to consider might be: def test(): r""" A different marker: >>> print 'a\n\nb' | a | | b """ I.e., the user can optionally preceed each line with a "|" (or some other marker), dedented past the prompt, to mark the extent of the output. I don't think this looks as wysiwyg, though. -Edward
[Edward Loper]
Perhaps you'd be happier with a different value of BLANKLINE_MARKER, then? E.g. "blank>":
def test(): r""" A different marker:
>>> print 'a\n\nb' a blank> b """
Although this means that you have to indent the doctest quite far. Perhaps it would be better if I changed the patch so the marker doesn't need to dedented all the way? E.g.:
def test(): r""" A different marker:
>>> print 'a\n\nb' a <blank line> b """
That's more what I had in mind, but if the marker is changed to something wordy instead of "a magic character", I don't think the dedent trick is of much value anymore: r""" A different marker: >>> print 'a\n\nb' a <blank line> b """ Then when the expected output is (exactly) "<blank line>", doctest would accept "<blank line>", or a line with nothing other than whitespace, as a match. I can't get upset by that bit of ambiguity. The primary advantage is that the implementation is then trivial, to write, document, and understand. It won't break external tools, and caters to leading, trailing, and embedded blank lines. It needs an option flag to turn it off, akin to the current doctest.DONT_ACCEPT_TRUE_FOR_1 (the only non-wysiwyg gimmick implemented now); it should be enabled by default.
Another option to consider might be:
def test(): r""" A different marker:
>>> print 'a\n\nb'
| a | | b """
I.e., the user can optionally preceed each line with a "|" (or some other marker), dedented past the prompt, to mark the extent of the output. I don't think this looks as wysiwyg, though.
Nope, it sure doesn't.
participants (2)
-
Edward Loper
-
Tim Peters