[Edu-sig] DocTest Quiz

Andre Roberge andre.roberge at gmail.com
Sun Apr 23 19:25:52 CEST 2006


On 4/23/06, Jeffrey Elkner <jeff at elkner.net> wrote:
[snip]
>
> Thanks, Michael!  I've written up a brief description of the tool I'm looking for here:
>
> http://dc.ubuntu-us.org/projects/doctest-quiz.php
[snip]

While it is not quite what Jeff described in the above quoted link,
you may want to check the newer version (1.9, released minutes ago) of
"lightning" to be found at:
https://sourceforge.net/project/showfiles.php?group_id=125834

Lightning is a wxPython-based app that I wrote to test code snippets. 
It is a "notebook" with two pages: one is a basic editor, the other is
a python shell.

I just added two options where one can run doctest on the code written
in the editor, either in basic or verbose mode, by pressing a button.
(The addition is a rush job; it works, but I will need to refactor the
code soon.)

You can test it with the example found at
http://www.python.org/doc/lib/module-doctest.html
All you need to do is copy the code in that page from
===
"""
This is the "example" module.

The example module supplies one function, factorial().  For example,

>>> factorial(5)
120
"""

def factorial(n):
#............  [snip]
    while factor <= n:
        result *= factor
        factor += 1
    return result
========
i.e. you do NOT need to add the following:
=====================
def _test():
    import doctest
    doctest.testmod()

if __name__ == "__main__":
    _test()
=======================

You can also try lightning with the example given in the link quoted
from Jeff's message.

Feel free to let me know your impressions!

André


More information about the Edu-sig mailing list