@@ -251,21 +251,18 @@ class PyobjMixin(PyobjContext):
251251 @property
252252 def obj (self ):
253253 """Underlying Python object."""
254- self ._mount_obj_if_needed ()
255- return self ._obj
256-
257- @obj .setter
258- def obj (self , value ):
259- self ._obj = value
260-
261- def _mount_obj_if_needed (self ):
262254 obj = getattr (self , "_obj" , None )
263255 if obj is None :
264256 self ._obj = obj = self ._getobj ()
265257 # XXX evil hack
266258 # used to avoid Instance collector marker duplication
267259 if self ._ALLOW_MARKERS :
268- self .own_markers .extend (get_unpacked_marks (obj ))
260+ self .own_markers .extend (get_unpacked_marks (self .obj ))
261+ return obj
262+
263+ @obj .setter
264+ def obj (self , value ):
265+ self ._obj = value
269266
270267 def _getobj (self ):
271268 """Gets the underlying Python object. May be overwritten by subclasses."""
@@ -432,14 +429,6 @@ def _genfunctions(self, name, funcobj):
432429class Module (nodes .File , PyCollector ):
433430 """ Collector for test classes and functions. """
434431
435- def __init__ (self , fspath , parent = None , config = None , session = None , nodeid = None ):
436- if fspath .basename == "__init__.py" :
437- self ._ALLOW_MARKERS = False
438-
439- nodes .FSCollector .__init__ (
440- self , fspath , parent = parent , config = config , session = session , nodeid = nodeid
441- )
442-
443432 def _getobj (self ):
444433 return self ._importtestmodule ()
445434
@@ -639,7 +628,6 @@ def isinitpath(self, path):
639628 return path in self .session ._initialpaths
640629
641630 def collect (self ):
642- self ._mount_obj_if_needed ()
643631 this_path = self .fspath .dirpath ()
644632 init_module = this_path .join ("__init__.py" )
645633 if init_module .check (file = 1 ) and path_matches_patterns (
0 commit comments