[TIP] suite, test_suite, load_tests ... Oh My ! WAS: unittest2 discovery / doctest integration?

Olemis Lang olemis at gmail.com
Tue May 4 10:02:37 PDT 2010

On 5/4/10, Michael Foord <fuzzyman at voidspace.org.uk> wrote:
> On 04/05/2010 12:29, Chris Withers wrote:
> > Michael Foord wrote:
> >
> > > Using load_tests seems like the best way to integrate doctests with
> > > unittest
> >
> > How does this match up with provided a test_suite function in the
> > module containing tests?
> >
> > I really hope that still works since it's a common paradigm supported
> > by at least trial and zope.testrunner.
> >
>  Have you tried it? :-) (Short story - it still works but isn't, and never
> was, used by the unittest test loader for loading tests from a module.)

AFAICS nobody mentioned unittest before (in the last few entries ) .
This convention is related to `setuptools` test command . IMHO once
upon a time `unittest` discovery should not have ignored this
convention deliberately in order to impose `load_tests` usage , but

This is an old subject , but I want to bring it back to life 'cause I
discovered the (probable) intention of the formerly documented
(PyUnit) `suite` function supplied in to `unittest.main` . I did so
after reviewing Trac XmlRpcPlugin code (yes, Trac guys are smarter
than me :P )
The following code was in a leaf test module (before recently released
XmlRpcPlugin 1.1.0 adding pluggable multi-protocol RPC architecture) :


def suite():
    return unittest.makeSuite(RpcWikiTestCase)

if __name__ == '__main__':


which is similar to what was documented in old docs. Besides in
top-level test module code looks like (kind of ;o)


def suite():
        suite = unittest.TestSuite()
        import tracrpc.tests.api
        import tracrpc.tests.xml_rpc
        import tracrpc.tests.json_rpc
        import tracrpc.tests.ticket
        import tracrpc.tests.wiki
        import tracrpc.tests.web_ui
        return suite


That's what suite was for in first place (even if that convention was
not enforced by unittest by default ;o)

More information about the testing-in-python mailing list