diff --git a/py/test/pycollect.py b/py/test/pycollect.py index a9dcc3f0d..ce09b4df5 100644 --- a/py/test/pycollect.py +++ b/py/test/pycollect.py @@ -149,7 +149,7 @@ class PyCollectorMixin(PyobjMixin, py.test.collect.Collector): class Module(py.test.collect.File, PyCollectorMixin): def collect(self): - if getattr(self.obj, 'disabled', 0): + if self.fspath.ext == ".py" and getattr(self.obj, 'disabled', 0): return [] return super(Module, self).collect() diff --git a/py/test/testing/test_deprecated_api.py b/py/test/testing/test_deprecated_api.py index 667e51b3d..8de8b6a44 100644 --- a/py/test/testing/test_deprecated_api.py +++ b/py/test/testing/test_deprecated_api.py @@ -135,3 +135,20 @@ class TestCollectDeprecated(suptest.InlineCollection): modcol = self.getmodulecol("def test_some(): pass") colitems = py.test.deprecated_call(modcol.collect) funcitem = colitems[0] + + def test_conftest_subclasses_Module_with_non_pyfile(self): + self.makepyfile(conftest=""" + import py + class Module(py.test.collect.Module): + def run(self): + return [] + class Directory(py.test.collect.Directory): + def consider_file(self, path, usefilters=True): + if path.basename == "testme.xxx": + return Module(path, parent=self) + return super(Directory, self).consider_file(path, usefilters=usefilters) + """) + testme = self._makefile('xxx', testme="hello") + config = self.parseconfig(testme) + col = config.getfsnode(testme) + assert col.collect() == []