Debugging doctests (was Re: [Zope3-dev] Re: Windows eggs)

2007-07-16 Thread Jim Fulton


On Jul 13, 2007, at 5:09 PM, Wichert Akkerman wrote:
...

Amen. I find failing doctests to be much harder to debug as well.


Are you are of the post-mortem debugging features of the zope.testing  
test runner?  I find this helps a lot when debugging test failures.



On Jul 14, 2007, at 1:00 PM, Wichert Akkerman wrote:
...

Until you have to step through the test with pdb, at which point it
becomes very painful.


It's true that you can't step across examples.  Of course, you can  
call pdb.set_trace on an example.  If you really need to step through  
multiple examples, you can combine the examples.  So, for example,  
you could convert:


x = f()
y = g(x)

to:

if 1:
   ...  x = f()
   ...  y = g(x)

For me, post-mortem debugging or using set_trace is almost always  
good enough. On those occasions where I really need to step through a  
series of example, It's straightforward to convert them to a single  
example.


In general I find well-written doctests easier to debug because they  
have documentation and the documentation makes their intent clearer.


Well written doctests will have documentation even when they aren't  
intended as documentation.  Of course, it could be argued that well  
written classic tests will have comments.  I think that doctest  
facilitates writing good tests, as I have see far more well-written  
doctests than I've seen well-written classic tests.


Jim

--
Jim Fulton  mailto:[EMAIL PROTECTED]Python 
Powered!
CTO (540) 361-1714  
http://www.python.org
Zope Corporationhttp://www.zope.com http://www.zope.org



___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: Debugging doctests (was Re: [Zope3-dev] Re: Windows eggs)

2007-07-16 Thread Stephan Richter
On Monday 16 July 2007 08:44, Jim Fulton wrote:
 For me, post-mortem debugging or using set_trace is almost always  
 good enough. On those occasions where I really need to step through a  
 series of example, It's straightforward to convert them to a single  
 example.

Me too. Actually I only use set_trace() and I always quickly find what I need.

 In general I find well-written doctests easier to debug because they  
 have documentation and the documentation makes their intent clearer.

I agree.

 Well written doctests will have documentation even when they aren't  
 intended as documentation.  Of course, it could be argued that well  
 written classic tests will have comments.  I think that doctest  
 facilitates writing good tests, as I have see far more well-written  
 doctests than I've seen well-written classic tests.

Amen. :-) I think we can say this about ourselves too. We (Zope 3 developers) 
have written much better tests since we started using doctests.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics  Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com