[TIP] Fwd: An OO API for doctest / unittest integration...

Olemis Lang olemis at gmail.com
Fri Aug 15 06:05:32 PDT 2008

2008/8/15, Olemis Lang <olemis at gmail.com>:
2008/8/14, Michał Kwiatkowski <constant.beta at gmail.com>:

> Hi,
 >  I downloaded your module, but haven't find a way to use it. Let's say
 >  I have a file with bunch of classes and functions in it. Most of their
 >  docstrings contain doctests. To run those tests using a standard
 >  doctest all I have to do is to run:
 >     import doctest
 >     doctest.testmod()

You are right... That also happens with the unittest API provided by
 doctest... ;) The fact is that we are still writing doctest examples.
 The difference is that we verify such examples employing a unittest
 test runner and we gather the match made for each example in a

 >  Is there a similar way to execute those doctests via dutest, so I can
 >  check out its new features?

I prefer you to read the article (see the links below), because there
 is comprehensive documentation and examples there...

 If you checked out the whole package (the trunk) using SVN... you can
take a look at the initialization of the default test
 loader employed in oop.test.test_oopdbc module...

 It looks something like this...

 defaultTestLoader= testing.WrapTopTestLoader(TS_DBC, \
dict(clear_globs= False))

 This means "In order to load the tests cases, gather first the
 outcomes from standard unittest loader (or what is the same build TestCase
 instances out of TestCase descendants). Next build some TestCases able
 to check the doctests included in my module (and when you run
 doctests, do not clear the global namespace -see DocTestRunner.run
 method- ). The suites created this way will be returned (wrapped by
 another test suite)... " The call made to testing.WrapTopTestLoader is
 specific to our testing environment... so it is not included with dutest...

 >  And another thing. You reference the article "Doctest and unittest…
 >  now they'll live happily forever". Is it available somewhere online?

Yes... take a look at TPP site [1]... you can download it directly from [2]

 [1] The Python Papers site

 [2] Direct link to the full issue (volume 3 issue 1)



More information about the testing-in-python mailing list