refactor disabling markers
This commit is contained in:
parent
b94eb4cb7b
commit
5cefcb2052
|
@ -432,6 +432,14 @@ class PyCollector(PyobjMixin, nodes.Collector):
|
||||||
class Module(nodes.File, PyCollector):
|
class Module(nodes.File, PyCollector):
|
||||||
""" Collector for test classes and functions. """
|
""" Collector for test classes and functions. """
|
||||||
|
|
||||||
|
def __init__(self, fspath, parent=None, config=None, session=None, nodeid=None):
|
||||||
|
if fspath.basename == "__init__.py":
|
||||||
|
self._ALLOW_MARKERS = False
|
||||||
|
|
||||||
|
nodes.FSCollector.__init__(
|
||||||
|
self, fspath, parent=parent, config=config, session=session, nodeid=nodeid
|
||||||
|
)
|
||||||
|
|
||||||
def _getobj(self):
|
def _getobj(self):
|
||||||
return self._importtestmodule()
|
return self._importtestmodule()
|
||||||
|
|
||||||
|
@ -548,15 +556,6 @@ class Module(nodes.File, PyCollector):
|
||||||
return mod
|
return mod
|
||||||
|
|
||||||
|
|
||||||
class InitModule(Module):
|
|
||||||
_ALLOW_MARKERS = False
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
if type(self) == InitModule:
|
|
||||||
return "<{} {}>".format(Module.__name__, getattr(self, "name", None))
|
|
||||||
return super().__repr__()
|
|
||||||
|
|
||||||
|
|
||||||
class Package(Module):
|
class Package(Module):
|
||||||
def __init__(self, fspath, parent=None, config=None, session=None, nodeid=None):
|
def __init__(self, fspath, parent=None, config=None, session=None, nodeid=None):
|
||||||
session = parent.session
|
session = parent.session
|
||||||
|
@ -646,7 +645,7 @@ class Package(Module):
|
||||||
if init_module.check(file=1) and path_matches_patterns(
|
if init_module.check(file=1) and path_matches_patterns(
|
||||||
init_module, self.config.getini("python_files")
|
init_module, self.config.getini("python_files")
|
||||||
):
|
):
|
||||||
yield InitModule(init_module, self)
|
yield Module(init_module, self)
|
||||||
pkg_prefixes = set()
|
pkg_prefixes = set()
|
||||||
for path in this_path.visit(rec=self._recurse, bf=True, sort=True):
|
for path in this_path.visit(rec=self._recurse, bf=True, sort=True):
|
||||||
# We will visit our own __init__.py file, in which case we skip it.
|
# We will visit our own __init__.py file, in which case we skip it.
|
||||||
|
|
Loading…
Reference in New Issue