Skip to content

Commit 4cc6bca

Browse files
author
Daniil Galiev
committed
disable _ALLOW_MARKERS in module __init__.py
1 parent 5b0a201 commit 4cc6bca

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/_pytest/python.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,15 @@ def _importtestmodule(self):
548548
return mod
549549

550550

551+
class InitModule(Module):
552+
_ALLOW_MARKERS = False
553+
554+
def __repr__(self):
555+
if type(self) == InitModule:
556+
return "<{} {}>".format(Module.__name__, getattr(self, "name", None))
557+
return super().__repr__()
558+
559+
551560
class Package(Module):
552561
def __init__(self, fspath, parent=None, config=None, session=None, nodeid=None):
553562
session = parent.session
@@ -637,7 +646,7 @@ def collect(self):
637646
if init_module.check(file=1) and path_matches_patterns(
638647
init_module, self.config.getini("python_files")
639648
):
640-
yield Module(init_module, self)
649+
yield InitModule(init_module, self)
641650
pkg_prefixes = set()
642651
for path in this_path.visit(rec=self._recurse, bf=True, sort=True):
643652
# We will visit our own __init__.py file, in which case we skip it.

0 commit comments

Comments
 (0)