resolves #59 - robustify unittest collection

--HG--
branch : trunk
This commit is contained in:
holger krekel 2009-10-09 15:09:26 +02:00
parent a603021757
commit f10bfbb7e5
3 changed files with 20 additions and 3 deletions

View File

@ -19,8 +19,13 @@ 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)
try:
isunit = issubclass(obj, py.std.unittest.TestCase)
except TypeError:
pass
else:
if isunit:
return UnitTestCase(name, parent=collector)
class UnitTestCase(py.test.collect.Class):
def collect(self):

View File

@ -1,6 +1,8 @@
Changes between 1.0.2 and '1.1.0b1'
=====================================
* fix issue #59 - robustify unittest test collection
* make bpython/help interaction work by adding an __all__ attribute
to ApiModule, cleanup initpkg

View File

@ -1,6 +1,5 @@
import py
def test_simple_unittest(testdir):
testpath = testdir.makepyfile("""
import unittest
@ -15,6 +14,17 @@ def test_simple_unittest(testdir):
assert reprec.matchreport("testpassing").passed
assert reprec.matchreport("test_failing").failed
def test_isclasscheck_issue53(testdir):
testpath = testdir.makepyfile("""
import unittest
class _E(object):
def __getattr__(self, tag):
pass
E = _E()
""")
result = testdir.runpytest(testpath)
assert result.ret == 0
def test_setup(testdir):
testpath = testdir.makepyfile(test_two="""
import unittest