bug in doctest?

Alexander Schmolck a.schmolck at gmx.net
Tue Jan 14 10:05:36 EST 2003


I ran into what I believe to be a bug in doctest and cost me quite a bit of
time.

Isn't doctest meant to work pretty much with unmodified interactive session
output (where that does make sense)? I doesn't seem to treat comments
correctly:

   import doctest, test
   def aTest():
       r""">>> # A comment
           ... print 'This is incorrectly ignored by doctest'
           This output here really doesn't matter either... (but SHOULD)
           >>>
           """
   doctest.testmod(test)

Doesn't produce any error. The print line and the (wrong) output following it
are just ignored. Changing '...' to '>>>' after the comment solves the
problem, but that means editing the interactive session output.


Also, wouldn't it be a good idea to (at least optionally) ignore memory
adresses in instance repr's that follow the pattern:

   <foo.Bar instance at 0x80d7624>

(i.e. see if the output matches something like (untested):

   ^<[\w.]+ instance at 0x([\da-f]+)>$

and if so ignore the last group?).


I could be convinced to submit a patch sometime if there is interest.

alex




More information about the Python-list mailing list