diff --git a/_py/test/plugin/pytest_unittest.py b/_py/test/plugin/pytest_unittest.py index 3572dadf6..3d92ce0c5 100644 --- a/_py/test/plugin/pytest_unittest.py +++ b/_py/test/plugin/pytest_unittest.py @@ -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): diff --git a/doc/changelog.txt b/doc/changelog.txt index d737a35ff..bb8d53097 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -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 diff --git a/testing/pytest/plugin/test_pytest_unittest.py b/testing/pytest/plugin/test_pytest_unittest.py index 3a87b3140..a43cb0326 100644 --- a/testing/pytest/plugin/test_pytest_unittest.py +++ b/testing/pytest/plugin/test_pytest_unittest.py @@ -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