[IPython-user] RE: doctest with ipython
Fernando Perez
Fernando.Perez at colorado.edu
Sun Apr 10 19:49:01 CDT 2005
Jon, I've added you to the whitelist on ipython-user for future posts.
Sorry, but I have no idea, given that I don't use doctest myself. I'm
forwarding your message to the list, hoping someone else may know. You'll
need to subscribe or scan the archives for replies.
Best,
f
ipython-user-bounces at scipy.net wrote:
> The attached message has been automatically discarded.
>
>
> ------------------------------------------------------------------------
>
> Subject: doctest with ipython
> From: Jon Schull <jschull at digitalgoods.com>
> Date: Sat, 9 Apr 2005 21:45:07 -0400
> To: IPython-user List <ipython-user at scipy.net>
>
>
> I have a feeling there's a cheat sheet somewhere explaining how to use
> doctest with ipython
>
> Given the doctest tester dtt.py
>
>>def double(x):
>> """>>> double(2)
>>45
>>"""
>> return 2*x
>>
>>def _test():
>> import doctest
>> doctest.testmod()
>>
>>if __name__ == "__main__":
>> _test()
>
>
> python dtt.py yields
>
>>Failure in example: double(2)
>>from line #0 of __main__.double
>>Expected: 45
>>Got: 4
>>*****************************************************************
>>1 items had failures:
>> 1 of 1 in __main__.double
>>***Test Failed*** 1 failures.
>
>
> but ipython yields
>
>
>>exceptions.TypeError Traceback (most
>>recent call last)
>>
>>/Users/jis/python/Tristan/dtt.py
>> 9 doctest.testmod()
>> 10
>> 11 if __name__ == "__main__":
>>---> 12 _test()
>> 13
>>
>>/Users/jis/python/Tristan/dtt.py in _test()
>> 7 def _test():
>> 8 import doctest
>>----> 9 doctest.testmod()
>> 10
>> 11 if __name__ == "__main__":
>>
>>/sw/src/root-python23-2.3.4-2/sw/lib/python2.3/doctest.py in
>>testmod(m, name, globs, verbose, isprivate, report, optionflags)
>> 1140
>> 1141 if not _ismodule(m):
>>-> 1142 raise TypeError("testmod: module required; " + `m`)
>> 1143 if name is None:
>> 1144 name = m.__name__
>>
>>TypeError: testmod: module required; <IPython.FakeModule instance>
>>WARNING: Failure executing file: <dtt.py>
>
>
> any clues?
>
> Thanks
>
>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> Jon Schull, Ph.D.
> Associate Professor
> Information Technology
> Rochester Institute of Technology
> 102 Lomb Memorial Drive
> Rochester, New York 14623
> schull at digitalgoods.com 585-738-6696
>
More information about the IPython-user
mailing list