[Zope-dev] Re: [zope.testing.doctest] a nasty surprise

2008-04-11 Thread Balazs Ree
On Thu, 10 Apr 2008 11:50:35 -0400, Benji York wrote:

 Dieter Maurer wrote:
 As the community (apparently) strongly favors doctest over
 unittest, I wrote my first test based on zope.testing.doctest. And
 promptly, I was badly surprised
 
 In order to analyse a difficult problem, I added from dm.pdb import
 zpdb; zpdb.set_trace() in the doctest (dm.pdb.zpdb is my Zope aware
 PDB extension)
 
 The standard PDB works fine.  I'm sure you're extended version can be
 tweaked to as well.

I have similar issues with ipdb. - similar in sense that I cannot use it 
when running from doctests.

ipdb is a lightweight component that enables entering ipython when 
import ipdb; ipdb.set_trace() is called. Those of you that use ipython 
and also develop with doctests a lot, will understand why it would be a 
nice to have also from doctests.

In case of ipdb I had no parameters problem like Dieter encountered with 
zpdb, however I observed that the doctest runner needs to redirect input 
and output while running tests, which are specifically routed back to 
stdin and stdout while pdb.set_trace is entered, to enable interactivity. 
This is done by monkeypatching pdb if I remember well. But the same does 
not happen with ipdb, of course.

So, my conclusion is that while doctests work well with the standard pdb, 
any alternate debugger must be supported explicitely (by changing the 
doctest code). As with ipdb, this may be the case with zpdb as well.

Best wishes


-- 
Balazs Ree

___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Re: [zope.testing.doctest] a nasty surprise

2008-04-11 Thread Dieter Maurer
Balazs Ree wrote at 2008-4-11 09:19 +0200:
 ...
 In order to analyse a difficult problem, I added from dm.pdb import
 zpdb; zpdb.set_trace() in the doctest (dm.pdb.zpdb is my Zope aware
 PDB extension)
 
 The standard PDB works fine.  I'm sure you're extended version can be
 tweaked to as well.

I have similar issues with ipdb. - similar in sense that I cannot use it 
when running from doctests.

Any any other debugger, too, will have problems.


Usually, I am no fan of explicit is better than implicit.
But, in this case, I think it would give a much better solution.

Apparently, the debugger integration works by wrapping
some class (_OutputRedirectingPdb) around a given debugger
and then use this debugger instead of the wrapped on.

How about documenting this wrapping class.
Then any debugger author can use the class to wrap his
debugger and use it.


For this special case, we do not need monkey patching.

import myWrappedDebugger; myWrappedDebugger.set_trace()

(or for the standard debugger:
from zope.testing import pdb; pdb.set_trace())

is only slightly more complex than

import pdb; pdb.set_trace()



-- 
Dieter
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )