[IPython-user] doctest support in 0.8.2

Fernando Perez fperez.net@gmail....
Thu Nov 22 15:14:11 CST 2007


On Nov 22, 2007 2:11 PM, Noah Gift <noah.gift@gmail.com> wrote:
> Is there any documentation on using doctest in 0.8.2?  That is one of the
> killer features I am waiting for.

In [7]: %doctest_mode?
Type:           Magic function
Base Class:     <type 'instancemethod'>
Namespace:      IPython internal
File:           /home/fperez/usr/lib/python2.5/site-packages/IPython/Magic.py
Definition:     %doctest_mode(self, parameter_s='')
Docstring:
    Toggle doctest mode on and off.

    This mode allows you to toggle the prompt behavior between normal
    IPython prompts and ones that are as similar to the default IPython
    interpreter as possible.

    It also supports the pasting of code snippets that have leading '>>>'
    and '...' prompts in them.  This means that you can paste doctests from
    files or docstrings (even if they have leading whitespace), and the
    code will execute correctly.  You can then use '%history -tn' to see
    the translated history without line numbers; this will give you the
    input after removal of all the leading prompts and whitespace, which
    can be pasted back into an editor.

    With these features, you can switch into this mode easily whenever you
    need to do testing and changes to doctests, without having to leave
    your existing IPython session.


I'm open to suggestions on how to improve it...

Cheers,

f


More information about the IPython-user mailing list