[IPython-user] [IPython-dev] Doctest fixes, testing release out

Jörgen Stenarson jorgen.stenarson@bostream...
Wed Aug 22 13:45:15 CDT 2007

Fernando Perez skrev:
> Hi all,
> over time, there have been repeated reports of doctest not working
> when running under IPython.  I think I finally fixed it deep enough
> that things should now work correctly in all cases, so that you can
> run any script or test suite that calls the various doctest testing
> runners, when inside ipython, and everything should just work.  If you
> are on SVN just update, or grab a testing release that I just made
> from current SVN here:
> http://ipython.scipy.org/dist/testing/
> I need these publicly available for a conference this week, and they
> wrap up all the recent fixes.  We'll start thinking about a release
> soon, but for now this will do.

This sounds great, unfortunately I can't get it to work using svn r2653.

Is there some extra configuration necessary, like updating configuration 

I have tried both on mac and win32 and get similar results, and the 
script works when running as python try_doctest.py


I have the following testfile (try_doctest.py)

import doctest

def a(x):
     >>> a(10)
     >>> a(31)
     return x+1

def _test():

if __name__=="__main__":

Resulting in the following ipython session:

Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.

IPython 0.8.2.svn.r2647 -- An enhanced Interactive Python.
?       -> Introduction to IPython's features.
%magic  -> Information about IPython's 'magic' % functions.
help    -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [1]: %run try_doctest.py
TypeError                                 Traceback (most recent call last)

      16 if __name__=="__main__":
---> 17     _test()
         _test = <function _test at 0x013DF0B0>

C:\python\ipython\try_doctest.py in _test()
      13 def _test():
---> 14     doctest.testmod()
         global doctest.testmod = <function testmod at 0x01277FB0>
      16 if __name__=="__main__":

c:\python24\lib\doctest.py in testmod(m=<IPython.FakeModule instance>, 
name=None, globs=None, verbose=None, isprivate=None, report=True, 
optionflags=0, extraglobs=None, raise_on_error=False, exclude_empty=False)
    1825     # Check that we were actually given a module.
    1826     if not inspect.ismodule(m):
-> 1827         raise TypeError("testmod: module required; %r" % (m,))
         global TypeError = undefined
         m = <IPython.FakeModule instance>
    1829     # If no name was given, then use the module's name.

TypeError: testmod: module required; <IPython.FakeModule instance>
WARNING: Failure executing file: <try_doctest.py>

In [2]:

More information about the IPython-user mailing list