[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:

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

I looked at the archives and found a suggestion:

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


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