@@ -216,18 +216,6 @@ def pytest_pycollect_makemodule(path, parent):
216
216
return Module (path , parent )
217
217
218
218
219
- def pytest_ignore_collect (path , config ):
220
- # Skip duplicate packages.
221
- keepduplicates = config .getoption ("keepduplicates" )
222
- if keepduplicates :
223
- duplicate_paths = config .pluginmanager ._duplicatepaths
224
- if path .basename == "__init__.py" :
225
- if path in duplicate_paths :
226
- return True
227
- else :
228
- duplicate_paths .add (path )
229
-
230
-
231
219
@hookimpl (hookwrapper = True )
232
220
def pytest_pycollect_makeitem (collector , name , obj ):
233
221
outcome = yield
@@ -554,9 +542,7 @@ def __init__(self, fspath, parent=None, config=None, session=None, nodeid=None):
554
542
self .name = fspath .dirname
555
543
self .trace = session .trace
556
544
self ._norecursepatterns = session ._norecursepatterns
557
- for path in list (session .config .pluginmanager ._duplicatepaths ):
558
- if path .dirname == fspath .dirname and path != fspath :
559
- session .config .pluginmanager ._duplicatepaths .remove (path )
545
+ self .fspath = fspath
560
546
561
547
def _recurse (self , path ):
562
548
ihook = self .gethookproxy (path .dirpath ())
@@ -594,6 +580,15 @@ def isinitpath(self, path):
594
580
return path in self .session ._initialpaths
595
581
596
582
def collect (self ):
583
+ # XXX: HACK!
584
+ # Before starting to collect any files from this package we need
585
+ # to cleanup the duplicate paths added by the session's collect().
586
+ # Proper fix is to not track these as duplicates in the first place.
587
+ for path in list (self .session .config .pluginmanager ._duplicatepaths ):
588
+ # if path.parts()[:len(self.fspath.dirpath().parts())] == self.fspath.dirpath().parts():
589
+ if path .dirname .startswith (self .name ):
590
+ self .session .config .pluginmanager ._duplicatepaths .remove (path )
591
+
597
592
this_path = self .fspath .dirpath ()
598
593
pkg_prefix = None
599
594
for path in this_path .visit (rec = self ._recurse , bf = True , sort = True ):
0 commit comments