doctest fails to NORMALIZE_WHITESPACE ?
David MacKay
mackay at aims.ac.za
Sat Dec 17 05:41:27 EST 2005
Thanks everyone! Silly me :-)
* Tim Peters <tim.peters at gmail.com> [2005-12-17 12:01]:
> [David MacKay]
> > Hello, I'm a python-list newbie. I've got a question about doctest; perhaps
> > a bug report.
>
> As things will turn out, it's just a question. That's common for newbies :-)
I've got a follow-up question motivated by my ugly backslash continuations.
> When Python doesn't "look clean", it's not Python -- and backslash
> continuation & semicolons often look like dirt to the experienced
> Python's eye.
The reason I was making those ugly single-line monsters was
I had somehow got the impression that each fresh line starting ">>>" was tested
_completely_separately_ by doctest; so, to preserve state I thought I had to write
>>> a=[2, 5, 1]; a.sort(); print a
[1, 2, 5]
rather than
>>> a=[2, 5, 1]
>>> a.sort()
>>> print a
[1, 2, 5]
But I see now I was wrong. Question:
Does doctest always preserve
state throughout the entire sequence of tests enclosed by `"""`, as if the tests were
entered in a single interactive session?
Or is there a way to instruct doctest to forget its state, and start
the next `>>>` with a clean slate?
Thanks very much!
David
--
--
David J.C. MacKay mackay at aims.ac.za 787 9336
http://www.aims.ac.za/~mackay/
More information about the Python-list
mailing list