[Tutor] doctest

Jacob S. keridee at jayco.net
Sun Jan 2 04:21:22 CET 2005


I think I'm losing my mind...

Maybe it's because I go back to school the day after tomorrow?
The thing that helped the most was the -v parameter...

Even so, doctest doesn't seem to recognize the module level docstring.
It will run the test inside the functions, but it says there isn't a test on
the module level.
I put the docstring just like in the example at the link you provided...

Also, anything I can do... Presently, since I'm running windows xp, I would
have to hunt for the command prompt and type in the command

'"C:\python24\python.exe" "C:\documents and settings\jacob\desktop\working
python programs\testmodules.py" -v'

...or make a batch file to do it for me...
How can I make testmodules.py (shown below) append the -v to itself? Is
there a self.results or something in testmod?

## testmodules.py ###########
import doctest

modtotest = 'FractionReducer2'

exec "import %s" % modtotest
doctest.testmod(eval(modtotest))
raw_input()
#############################


Thanks,
Jacob Schmidt


> What docs are you looking at?? The module docs at
http://docs.python.org/lib/module-doctest.html
> have a complete example of testing a module with a main function. Or you
can use the code in my last
> post.
>
> Kent
>
> Jacob S. wrote:
> > Hi.
> >
> >     Okay, so I look at the documentation at it says (in my words):
> >
> > "First Class - DocTest -- Make a test object with such and such
attributes
> > that you can test.
> > Second Class - i don't remember the name - Make Jacob look stupid with
big
> > words
> > Third Class - DocTestSuite - Convert a doctest object to a unittest
object -
> > Okay... so how does that help?
> > Fourth Class - DocTestFinder - Find the docstrings that contain test
code
> > and extract them."
> >
> > So, my question, I guess, is How did the documentation help, and, How do
I
> > have doctest test all of my module's function's docstrings?
> >
> > Thanks in advance,
> > Jacob Schmidt
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>



More information about the Tutor mailing list