[TIP] Building a unittest.TestCase from a doctest

jason pellerin jpellerin at gmail.com
Tue Dec 18 11:32:41 PST 2007


Apologies for the partial reply just sent (probably to Jim alone)...
my fingers evidently don't know the gmail keyboard commands as well as
they think they do. :/

> > (There's a reason I use nose: I've never understood unittest.)
>
>
> I thought nose was a test runner for unittest. I guess not.

nose runs unittest tests, and doctests and py.test-style test
functions and classes, and other kinds via non-built-in plugins. I
think Titus is just saying that he likes to write test functions like:

def test():
    pass

and let nose figure out how to make them into unittest.TestCases,
rather than writing the TestCases himself. More or less?

>  It was my understanding that nose can
> also run unittest suites.

It can, and doctests as well. It does that by turning everything into
instances of TestCase (or a subclass). There are some additional bells
and whistles provided by the test runner, suite and test result
classes that nose uses, but the core is an extensible test loader that
knows how to turn more stuff into TestCases than the stock
unittest.TestLoader.

> Perhaps there is or should be a better integration of doctest and nose
> that bypasses the unittest framework.  I originally integrated doctest
> and unittest because unittest was part of the standard library.
>
> I really need to learn about nose some day. :/

My doc-writing skills are nearly as poor as my gmail-controlling
skills, but the main doc has been through many rounds of users telling
me how bad it is and is, I think, not so bad anymore:

http://somethingaboutorange.com/mrl/projects/nose/

JP



More information about the testing-in-python mailing list