[TIP] Doctest loading in unittest(2)

Michael Foord michael at voidspace.org.uk
Fri Jul 30 07:35:49 PDT 2010


Hello all,

(Especially Barry who has expressed a particular interest in this topic.)

The unittest2 plugins branch includes an example plugin for loading and 
running doctests from a project.

For getting started with trying out the plugins branch see this blog entry:

http://www.voidspace.org.uk/python/weblog/arch_d7_2010_07_24.shtml#e1186

The doctest loading plugin is very primitive. During test discovery it 
loads *all* text files with doctest.DocFileTest(path, 
module_relative=False). You can also pass a path to a text file to the 
unit2 test runner. The plugin is enabled with a command line switch 
(on/off) or by setting "always-on = True" in the "[doctest]" section of 
the config file.

The doctestloader plugin source code (all 25 lines of it) can be seen at:

http://hg.python.org/unittest2/file/tip/unittest2/plugins/doctestloader.py

This is one of the plugins I think we could distribute as part of 
unittest and I would like it to be actually useful. I would really 
appreciate advice (or preferably patches ;-) on what features this 
plugin needs to be useful to those of you who integrate doctests with 
unittests - or even just want test discovery for doctests.

All the best,

Michael

-- 
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog

READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.





More information about the testing-in-python mailing list