[IPython-user] Using doctest in IPython

Ethan Kennerly kennerly@finegamedesign....
Thu Jun 21 21:05:20 CDT 2007


I like the features that IPython has:
http://www.onlamp.com/pub/a/python/2005/01/27/ipython.html?page=1

I like how it reloads modules, and how it feels side-by-side with gVim for
editing Python code.

But there's two gotchas that have been frustrating my effort to use IPython,
which made it more troublesome than beneficial to my work style.

1)  I don't know how to make IPython use a doctest.  When I try, the output
becomes conflated with the interpreter's output.
IDLE handles doctest correctly.  Is there a configuration option or
workaround for IPython to handle a standard doctest?  (I'm not interested in
discussing the virtues of unittest over doctest at this time.)

2)  Related to the first, to troubleshoot code, I place a breakpoint in the
doctest, which works with pdb in IDLE.  How would I go about this in
IPython?

I looked at the archives and found a suggestion:
http://lists.ipython.scipy.org/pipermail/ipython-user/2007-January/004017.ht
ml

But that did not modify the error.  I noticed that I am using Windows and
saw that pyreadline needed a workaround.

http://sourceforge.net/tracker/index.php?func=detail&aid=1708316&group_id=54
70&atid=105470

I looked at the workaround for pyreadline, but I'm afraid I need a little
more verbose help than that.  And it seems untenable to hack the sys module
after the doctest is loaded.

Tab-completion and other niceties are less important than getting inside the
doctest and debugging the code.  So if there is a method that disables
pyreadline, or any other IPython I/O convenience, and enables doctest, I'd
like to try it!

Thanks for your help,

-- Ethan




More information about the IPython-user mailing list