annoying doctest problem

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Jan 12 08:00:21 EST 2015


Skip Montanaro wrote:

> ISTR that when Tim Peters first implemented first, the typical way you
> were expected to get tests into a doc string was to copy from an
> interactive session, which would not have this problem.

I believe that is still documented as the way to generate doctests.
 
> Also, to Steven's comment about fussiness, it isn't so much that it's
> fussy. It's more that it's dumb. I just does a simple string comparison of
> the expected and actual outputs. It would be impossible for doctest to
> know whether the expected output was something like repr or str output,
> and thus safe to exchange single for double (don't forget to escape other
> embedded quotes!), or was some sort of user-generated string, perhaps
> intended to be
> text in  another programming language which has different quoting rules
> than Python. Therefore, fussy (or dumb) is exactly what you want.

I didn't mean to give the impression that doctest was wrong to be fussy, or
dumb if you prefer. I think it's exactly the right behaviour.



-- 
Steven




More information about the Python-list mailing list