[svn r57834] try to accomodate the fact that some conftests like the Prolog-test ones
subclass Module but do not actually have an underlying python file. Nowadays, they should subclass "py.test.collect.File". --HG-- branch : trunk
This commit is contained in:
parent
a978e606c3
commit
e29a48b575
|
@ -149,7 +149,7 @@ class PyCollectorMixin(PyobjMixin, py.test.collect.Collector):
|
||||||
|
|
||||||
class Module(py.test.collect.File, PyCollectorMixin):
|
class Module(py.test.collect.File, PyCollectorMixin):
|
||||||
def collect(self):
|
def collect(self):
|
||||||
if getattr(self.obj, 'disabled', 0):
|
if self.fspath.ext == ".py" and getattr(self.obj, 'disabled', 0):
|
||||||
return []
|
return []
|
||||||
return super(Module, self).collect()
|
return super(Module, self).collect()
|
||||||
|
|
||||||
|
|
|
@ -135,3 +135,20 @@ class TestCollectDeprecated(suptest.InlineCollection):
|
||||||
modcol = self.getmodulecol("def test_some(): pass")
|
modcol = self.getmodulecol("def test_some(): pass")
|
||||||
colitems = py.test.deprecated_call(modcol.collect)
|
colitems = py.test.deprecated_call(modcol.collect)
|
||||||
funcitem = colitems[0]
|
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() == []
|
||||||
|
|
Loading…
Reference in New Issue