[Tutor] problems with doctest: apparent interferance between tests (LONG)

Brian van den Broek bvande at po-box.mcgill.ca
Sun Apr 10 17:26:02 CEST 2005


John Ridley said unto the world upon 2005-04-10 10:05:
> Hello Brian
> 
> I think the source of your problem is that the second instance of
> Wall_clock doesn't get deleted in the interval doctest. This is
> critical, because the is_instanced attribute is reset by __del__.
> 
> 
>>  def interval(self, interval_name = None):
>>      '''
>>      >>> # print "Testing interval (intentional fail)."
>>      >>> wc = Wall_clock()
>>      >>> del(wc)
>>      >>> wclock = Wall_clock()
> 
> 
> As a quick hack, try adding the following line here:
> 
>         >>> wclock.__del__()
> 
> HTH
> 
> John Ridley

Hi John,

thanks *very* much for making it through my long post :-)

Your suggestion of
     >>> wclock.__del__()
does indeed work. Thanks.

But it leaves me with some of the same puzzles as before and adds a 
new one.

The new:
 >>> wclock.__del__() works whereas:
     >>> del(wclock)
does not. But del(foo) calls foo's __del__ method if defined (as it is 
in this case). So, I don't understand why the two ought be different.

The old:
Your addition does make it work in the code as I posted. But 1) I 
thought doctests embedded in different methods' docstrings were 
supposed to be independent, and 2) none of that explains why the 
presence or absence of the various things outside of the docstring at 
issue and mentioned in my original post make a difference.

So, your suggestion leaves me able to test my code; for that I am most 
appreciative. But I still have an uncomfortable sensation that 
something is truly amiss.

Thanks again and best,

Brian vdB



More information about the Tutor mailing list