[Zope3-Users] Re: [Zope] Debugging doctests

Gary Poster gary at zope.com
Thu Feb 23 10:11:07 EST 2006


On Feb 23, 2006, at 8:13 AM, Lennart Regebro wrote:

> On 2/23/06, Stephan Richter <srichter at cosmos.phy.tufts.edu> wrote:
>> How do you want to use the debugger?
>
> I'd like to be able to step through the tests.

You effectively can't step through all the tests (with a single  
pdb).  You can step through a single line in the test well.  While it  
sounds limiting, that has proved quite sufficient for me in  
practice.  YMMV, of course.

>> I run the tests, if the set_trace()
>> occurs it throws me to the prompt and all is fine. I can use the  
>> debugger as
>> usual.
>
> When I do this, I get a prompt. Pressing next returns to the running
> of the tests, not the next line of the test. Here is an example:
>
>>>> import pdb;pdb.set_trace()
>>>> gsm = zope.component.getGlobalSiteManager()
>>>> gsm.provideUtility(I1, ob)
>>>> gsm.provideUtility(I11, ob11)

Yup, that won't work.  You need to put the pdb on the same line as  
the thing you want to trace, i.e.

>>>> import pdb;pdb.set_trace(); gsm =  
>>>> zope.component.getGlobalSiteManager()
>>>> gsm.provideUtility(I1, ob)
>>>> gsm.provideUtility(I11, ob11)

That would let you trace the getGlobalSiteManager call.  If you  
wanted to trace the provideUtility calls then you would want to put a  
pdb in there too.  I don't think I've ever had more than one in at a  
time, though.

Gary


More information about the Zope3-users mailing list