From b94eb4cb7b455282144e99e9c0b21aa80596e993 Mon Sep 17 00:00:00 2001 From: Daniil Galiev Date: Thu, 12 Sep 2019 01:57:04 +0500 Subject: [PATCH] disable _ALLOW_MARKERS in module __init__.py --- src/_pytest/python.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 97a3ac805..a1f6d5067 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -548,6 +548,15 @@ 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 @@ -637,7 +646,7 @@ class Package(Module): if init_module.check(file=1) and path_matches_patterns( init_module, self.config.getini("python_files") ): - yield Module(init_module, self) + yield InitModule(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.