[TIP] unittest2, distribute, and doctests
Michael Foord
fuzzyman at voidspace.org.uk
Thu Jun 10 05:21:55 PDT 2010
On 7 June 2010 22:43, Barry Warsaw <barry at python.org> wrote:
> Hey guys, I have a few quick questions about unittest2. Apologies if these
> have been discussed before.
>
> Distribute adds the ability to run 'python setup.py test' by including the
> `test_suite` keyword to your setup(). What's the best way to integrate
> unittest2 and distribute to enable the former to do test discovery when run
> via the setup.py?
>
>
Note that I have now implemented a setuptools compatible test collector for
unittest2.
http://hg.python.org/unittest2/file/11200ca25af1/unittest2/collector.py
As you can see it is very simple... :-) It will be in version 0.5.0 of
unittest2.
If you specify "test_suite = 'unittest2.collector'" in your setup.py, then
the distribute / setuptools test command (setup.py test) launches test
discovery (with the default parameters) from the current directory.
As it isn't configurable (making unittest2 extensible and configurable on a
per project basis is a task for after Python 2.7 is released) it is perhaps
most useful at the moment as an example.
All the best,
Michael Foord
> `python setup.py test` supports a -m and -s option to filter (minimally)
> the
> tests that are run. Can unittest2's richer command line options be
> supported?
> (This may be more of a distutils/setuptools/distribute question.)
>
> unit2 -p takes shell globs, but I really like zope.testrunner's
> regexp-based
> filters. Any chance unittest2 will support something like that? One of
> the
> reasons I like zope's test discovery is because it works much better with
> doctests. E.g. I can do (after a buildout):
>
> % bin/test -vv -t using
>
> and it will only run my using.txt doctest. Note that I have a test_docs.py
> module that does individual .txt doctest discovery, wrapping each one in a
> DocFileSuite with appropriate optionflags, and setUp. IWBNI unittest2
> eventually grew better support for doctests.
>
> Is it intentional that a module's load_tests() not called when unit2 -p is
> used?
>
> Cheers,
> -Barry
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
>
>
--
http://www.voidspace.org.uk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20100610/cd8cc246/attachment.html>
More information about the testing-in-python
mailing list