[py-svn] py-trunk commit bb70d1a4e812: resolves #59 - robustify unittest collection
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Fri Oct 9 15:27:10 CEST 2009
# HG changeset patch -- Bitbucket.org
# Project py-trunk
# URL http://bitbucket.org/hpk42/py-trunk/overview/
# User holger krekel <holger at merlinux.eu>
# Date 1255093766 -7200
# Node ID bb70d1a4e812d729bf65bf19e56c575fe5d24b20
# Parent 6717b729d59a8dabd18a0d922bc2102a2565c1aa
resolves #59 - robustify unittest collection
--- 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
--- 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):
--- 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
More information about the pytest-commit
mailing list