refactor disabling markers

This commit is contained in:
Daniil Galiev 2019-09-28 00:06:46 +05:00 committed by Daniel Hahler
parent b94eb4cb7b
commit 5cefcb2052
1 changed files with 9 additions and 10 deletions

View File

@ -432,6 +432,14 @@ class PyCollector(PyobjMixin, nodes.Collector):
class Module(nodes.File, PyCollector):
""" 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):
return self._importtestmodule()
@ -548,15 +556,6 @@ class Module(nodes.File, PyCollector):
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):
def __init__(self, fspath, parent=None, config=None, session=None, nodeid=None):
session = parent.session
@ -646,7 +645,7 @@ class Package(Module):
if init_module.check(file=1) and path_matches_patterns(
init_module, self.config.getini("python_files")
):
yield InitModule(init_module, self)
yield Module(init_module, self)
pkg_prefixes = set()
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.