improve unittest documentation, enable plugin by default
--HG-- branch : 1.0.x
This commit is contained in:
parent
16aa1571c0
commit
4f735a66c5
|
@ -10,5 +10,5 @@ Generator = py.test.collect.Generator
|
||||||
Function = py.test.collect.Function
|
Function = py.test.collect.Function
|
||||||
Instance = py.test.collect.Instance
|
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()
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,24 @@
|
||||||
"""
|
"""
|
||||||
automatically discover and run traditional "unittest.py" style tests.
|
automatically discover and run traditional "unittest.py" style tests.
|
||||||
|
|
||||||
you can mix unittest TestCase subclasses and
|
Usage
|
||||||
py.test style tests in one test module.
|
----------------
|
||||||
|
|
||||||
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
|
This plugin is enabled by default.
|
||||||
|
|
||||||
http://johnnydebris.net/svn/projects/py_unittest
|
|
||||||
|
|
||||||
|
.. _`unittest.py style`: http://docs.python.org/library/unittest.html
|
||||||
"""
|
"""
|
||||||
import py
|
import py
|
||||||
|
import sys
|
||||||
|
|
||||||
def pytest_pycollect_makeitem(collector, name, obj):
|
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):
|
if py.std.inspect.isclass(obj) and issubclass(obj, py.std.unittest.TestCase):
|
||||||
return UnitTestCase(name, parent=collector)
|
return UnitTestCase(name, parent=collector)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue