[IPython-User] Doctest checker in IPython notebook

Thomas Kluyver takowl@gmail....
Thu Oct 11 10:34:41 CDT 2012


I spotted this on Planet Python. Catherine Devlin (CCed) has made a
tool to doctest a function and display the results in a nice HTML
format, for use with the notebook:

http://catherinedevlin.blogspot.co.uk/2012/10/im-increasingly-amazed-at-ipython.html

In the discussion recently about teaching with the notebook, we
mentioned the possibility of homework notebooks where the student has
to fill in code, so something like this could be really useful.

I wonder if there's a better way than using doctests, though (doctests
being my pet hate)? It would be easy to define a list of input/output
pairs, but all the tuples involved would make writing the tests
awkward. Maybe a cell magic:

%%check_cases
cube(3) == 27
cube(-2) == -8

Thomas


More information about the IPython-User mailing list