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

Marius Gedminas mgedmin at b4net.lt
Thu Apr 10 15:37:10 EDT 2008


On Thu, Apr 10, 2008 at 08:46:15PM +0200, Dieter Maurer wrote:
> Benji York wrote at 2008-4-10 11:50 -0400:
> >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.
> 
> Does a documentation exist how "doctest" manipulates "set_trace"
> and what it expects that the manipulation succeeds.

Documentation?  Well, there are some comments in the source file...

doctest monkey-patches pdb.set_trace (in an ugly way, IMHO) to restore
sys.stdout, because you want the output from pdb commands like 'list' or
'print' to go to your console, and not to the doctest's actual result
StringIO collector.

> Apparently, "doctest" has replaced my "set_trace" in "zpdb"
> by its non working implementation of "set_trace".

I find it hard to believe.  It's more likely that zpdb is interacting
with pdb.set_trace in a way that conflicts with doctest's monkey-patch.

Is the zdpb module available on the web somewhere?

> I can understand that my "set_trace" would not have worked
> (as probably "sys.stdout/err" points somewhere else then usual),
> but I have difficulties to understand why "doctest"'s "set_trace"
> does not work (at all).

Marius Gedminas
-- 
...Unix, MS-DOS, and Windows NT (also known as the Good, the Bad, and
the Ugly).
                -- Matt Welsh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope-dev/attachments/20080410/b2b79edb/attachment-0001.bin


More information about the Zope-Dev mailing list