[TIP] unittest2 discovery / doctest integration?
fuzzyman at voidspace.org.uk
Thu Apr 29 07:24:43 PDT 2010
On 28/04/2010 22:53, Pete wrote:
> On Apr 28, 2010, at 4:26 PM, Pete wrote:
>> Appears the way to do this goes like so. In your mostly-unittests test module, define a load_tests:
>> def load_tests(loader, tests, ignore):
>> return tests
>> Pretty straightforward, though not at all obvious. Looks like the documentation for doctest could use an update... http://docs.python.org/dev/library/doctest.html#unittest-api I'd write a patch (hello-to-my-friend-jesse-noller), but I'm not entirely sure what to say (tl;dr) - would replacing the code sample& changing its description to read "To integrate with unittest discovery, include the following in a module of unittests:" suffice?
> I just went ahead and created bug 8564 w/ a patch if anyone cares. Thanks all.
Using load_tests seems like the best way to integrate doctests with
unittest test discovery to me. When unittest is more extensible there
may be a better way (creating a doctest loader to inspect modules), but
for now this is the best way.
I'll commit the doctest documentation update next time I set aside some
"core python" time.
All the best,
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
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