From 2cb7e725ce30d99153af0ed8cf62e534088d5179 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Wed, 21 Mar 2018 07:21:54 +0100 Subject: [PATCH] document the hack used to avoid duplicate markers due Instance collectors --- _pytest/python.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/_pytest/python.py b/_pytest/python.py index 86c3be447..d85f4a89e 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -219,6 +219,7 @@ class PyobjMixin(PyobjContext): if obj is None: self._obj = obj = self._getobj() # XXX evil hack + # used to avoid Instance collector marker duplication if self._ALLOW_MARKERS: self._markers.update(get_unpacked_marks(self.obj)) return obj @@ -535,6 +536,9 @@ class Class(PyCollector): class Instance(PyCollector): _ALLOW_MARKERS = False # hack, destroy later + # instances share the object with their parents in a way + # that duplicates markers instances if not taken out + # can be removed at node strucutre reorganization time def _getobj(self): return self.parent.obj()