[py-svn] commit/pytest: hpk42: fix issue33 - no collection error for classes prefixed "test" deriving from object
Bitbucket
commits-noreply at bitbucket.org
Wed Mar 16 16:36:38 CET 2011
1 new changeset in pytest:
http://bitbucket.org/hpk42/pytest/changeset/6c9eb22fb7a3/
changeset: r2188:6c9eb22fb7a3
user: hpk42
date: 2011-03-16 16:36:18
summary: fix issue33 - no collection error for classes prefixed "test" deriving from object
affected #: 5 files (523 bytes)
--- a/CHANGELOG Sat Mar 12 20:12:19 2011 +0100
+++ b/CHANGELOG Wed Mar 16 16:36:18 2011 +0100
@@ -1,6 +1,9 @@
Changes between 2.0.2 and 2.0.3.dev
----------------------------------------------
+- fix issue34: avoid collection failure with "test" prefixed classes
+ deriving from object.
+
- don't require zlib (and other libs) for genscript plugin without
--genscript actually being used.
--- a/_pytest/python.py Sat Mar 12 20:12:19 2011 +0100
+++ b/_pytest/python.py Wed Mar 16 16:36:18 2011 +0100
@@ -70,11 +70,13 @@
res = __multicall__.execute()
if res is not None:
return res
- if collector._istestclasscandidate(name, obj):
+ if inspect.isclass(obj):
#if hasattr(collector.obj, 'unittest'):
# return # we assume it's a mixin class for a TestCase derived one
- Class = collector._getcustomclass("Class")
- return Class(name, parent=collector)
+ if collector.classnamefilter(name):
+ if not hasinit(obj):
+ Class = collector._getcustomclass("Class")
+ return Class(name, parent=collector)
elif collector.funcnamefilter(name) and hasattr(obj, '__call__'):
if is_generator(obj):
return Generator(name, parent=collector)
@@ -194,14 +196,6 @@
return self.ihook.pytest_pycollect_makeitem(
collector=self, name=name, obj=obj)
- def _istestclasscandidate(self, name, obj):
- if self.classnamefilter(name) and \
- inspect.isclass(obj):
- if hasinit(obj):
- # XXX WARN
- return False
- return True
-
def _genfunctions(self, name, funcobj):
module = self.getparent(Module).obj
clscol = self.getparent(Class)
--- a/pytest.py Sat Mar 12 20:12:19 2011 +0100
+++ b/pytest.py Wed Mar 16 16:36:18 2011 +0100
@@ -1,7 +1,7 @@
"""
unit and functional testing with Python.
"""
-__version__ = '2.0.3.dev1'
+__version__ = '2.0.3.dev2'
__all__ = ['main']
from _pytest.core import main, UsageError, _preloadplugins
--- a/setup.py Sat Mar 12 20:12:19 2011 +0100
+++ b/setup.py Wed Mar 16 16:36:18 2011 +0100
@@ -22,7 +22,7 @@
name='pytest',
description='py.test: simple powerful testing with Python',
long_description = long_description,
- version='2.0.3.dev1',
+ version='2.0.3.dev2',
url='http://pytest.org',
license='MIT license',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
--- a/testing/test_python.py Sat Mar 12 20:12:19 2011 +0100
+++ b/testing/test_python.py Wed Mar 16 16:36:18 2011 +0100
@@ -46,6 +46,16 @@
l = modcol.collect()
assert len(l) == 0
+ def test_class_subclassobject(self, testdir):
+ testdir.getmodulecol("""
+ class test(object):
+ pass
+ """)
+ result = testdir.runpytest()
+ result.stdout.fnmatch_lines([
+ "*collected 0*",
+ ])
+
class TestGenerator:
def test_generative_functions(self, testdir):
modcol = testdir.getmodulecol("""
Repository URL: https://bitbucket.org/hpk42/pytest/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the pytest-commit
mailing list