1 new commit in pytest: https://bitbucket.org/hpk42/pytest/commits/18234e3726bf/ changeset: 18234e3726bf user: RonnyPfannschmidt date: 2013-02-15 10:18:00 summary: fix issue 251 - report a skip instead of ignoring classes with init affected #: 3 files
diff -r 62984b8b62e8bfe8840fe1fe5c8751f04d1edce4 -r 18234e3726bf090183d0cf7cc76c58ac89c179fb CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ Changes between 2.3.4 and 2.3.5dev ----------------------------------- +- issue 251 - report a skip instead of ignoring classes with init - issue250 unicode/str mixes in parametrization names and values now works diff -r 62984b8b62e8bfe8840fe1fe5c8751f04d1edce4 -r 18234e3726bf090183d0cf7cc76c58ac89c179fb _pytest/python.py --- a/_pytest/python.py +++ b/_pytest/python.py @@ -175,9 +175,8 @@ #if hasattr(collector.obj, 'unittest'): # return # we assume it's a mixin class for a TestCase derived one if collector.classnamefilter(name): - if not hasinit(obj): - Class = collector._getcustomclass("Class") - return Class(name, parent=collector) + 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) @@ -394,6 +393,11 @@ class Class(PyCollector): """ Collector for test methods. """ def collect(self): + if hasinit(self.obj): + pytest.skip("class %s.%s with __init__ won't get collected" % ( + self.obj.__module__, + self.obj.__name__, + )) return [self._getcustomclass("Instance")(name="()", parent=self)] def setup(self): diff -r 62984b8b62e8bfe8840fe1fe5c8751f04d1edce4 -r 18234e3726bf090183d0cf7cc76c58ac89c179fb testing/python/collect.py --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -35,7 +35,7 @@ pytest.raises(ImportError, "modcol.obj") class TestClass: - def test_class_with_init_not_collected(self, testdir): + def test_class_with_init_skip_collect(self, testdir): modcol = testdir.getmodulecol(""" class TestClass1: def __init__(self): @@ -45,7 +45,10 @@ pass """) l = modcol.collect() - assert len(l) == 0 + assert len(l) == 2 + + for classcol in l: + pytest.raises(pytest.skip.Exception, classcol.collect) def test_class_subclassobject(self, testdir): 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. _______________________________________________ pytest-commit mailing list pytest-commit@python.org http://mail.python.org/mailman/listinfo/pytest-commit