improve unittest documentation, enable plugin by default

--HG--
branch : 1.0.x
This commit is contained in:
holger krekel 2009-07-20 18:54:18 +02:00
parent 16aa1571c0
commit 4f735a66c5
2 changed files with 12 additions and 7 deletions

View File

@ -10,5 +10,5 @@ Generator = py.test.collect.Generator
Function = py.test.collect.Function
Instance = py.test.collect.Instance
pytest_plugins = "default runner terminal keyword xfail tmpdir execnetcleanup monkeypatch recwarn pdb".split()
pytest_plugins = "default runner terminal keyword xfail tmpdir execnetcleanup monkeypatch recwarn pdb unittest".split()

View File

@ -1,19 +1,24 @@
"""
automatically discover and run traditional "unittest.py" style tests.
you can mix unittest TestCase subclasses and
py.test style tests in one test module.
Usage
----------------
XXX consider user-specified test_suite()
This plugin collects and runs Python `unittest.py style`_ tests.
It will automatically collect ``unittest.TestCase`` subclasses
and their ``test`` methods from the test modules of a project
(usually following the ``test_*.py`` pattern).
this code is somewhat derived from Guido Wesdorps
http://johnnydebris.net/svn/projects/py_unittest
This plugin is enabled by default.
.. _`unittest.py style`: http://docs.python.org/library/unittest.html
"""
import py
import sys
def pytest_pycollect_makeitem(collector, name, obj):
if 'unittest' not in sys.modules:
return # nobody could have possibly derived a subclass
if py.std.inspect.isclass(obj) and issubclass(obj, py.std.unittest.TestCase):
return UnitTestCase(name, parent=collector)