Merge Christian Kampka's patch to give us distutils test running support.

This commit is contained in:
Jonathan Lange
2011-04-01 14:19:34 +01:00
4 changed files with 39 additions and 0 deletions

2
NEWS
View File

@@ -50,6 +50,8 @@ Improvements
* ``setup.py`` can now build a snapshot when Bazaar is installed but the tree
is not a Bazaar tree. (Jelmer Vernooij)
* Support for running tests using distutils (Christian Kampka, #726539)
* Vastly improved and extended documentation. (Jonathan Lange)
* Use unittest2 exception classes if available. (Jelmer Vernooij)

View File

@@ -88,6 +88,34 @@ of them will happily run testtools tests. In particular:
From now on, we'll assume that you know how to run your tests.
Running test with Distutils
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you are using Distutils_ to build your Python project, you can use the testtools
Distutils_ command to integrate testtools into your Distutils_ workflow::
from distutils.core import setup
from testtools import TestCommand
setup(name='foo',
version='1.0',
py_modules=['foo'],
cmdclass={'test': TestCommand}
)
You can then run::
$ python setup.py test -m exampletest
Tests running...
Ran 2 tests in 0.000s
OK
For more information about the capabilities of the `TestCommand` command see::
$ python setup.py test --help
You can use the `setup configuration`_ to specify the default behavior of the
`TestCommand` command.
Assertions
==========
@@ -1098,3 +1126,5 @@ You can do::
.. _Deferred: http://twistedmatrix.com/documents/current/core/howto/defer.html
.. _discover: http://pypi.python.org/pypi/discover
.. _`testtools API docs`: http://mumak.net/testtools/apidocs/
.. _Distutils: http://docs.python.org/library/distutils.html
.. _`setup configuration`: http://docs.python.org/distutils/configfile.html

4
setup.cfg Normal file
View File

@@ -0,0 +1,4 @@
[test]
test_module = testtools.tests
buffer=1
catch=1

View File

@@ -61,6 +61,9 @@ from testtools.testsuite import (
ConcurrentTestSuite,
iterate_tests,
)
from testtools.distutilscmd import (
TestCommand,
)
# same format as sys.version_info: "A tuple containing the five components of
# the version number: major, minor, micro, releaselevel, and serial. All