File tree 4 files changed +12
-19
lines changed
4 files changed +12
-19
lines changed Original file line number Diff line number Diff line change
1
+ Fix collecting test from package ``__init__.py `` files.
Original file line number Diff line number Diff line change @@ -281,15 +281,6 @@ def pytest_ignore_collect(path, config):
281
281
if _in_venv (path ) and not allow_in_venv :
282
282
return True
283
283
284
- # Skip duplicate paths.
285
- keepduplicates = config .getoption ("keepduplicates" )
286
- duplicate_paths = config .pluginmanager ._duplicatepaths
287
- if not keepduplicates :
288
- if path in duplicate_paths :
289
- return True
290
- else :
291
- duplicate_paths .add (path )
292
-
293
284
return False
294
285
295
286
@@ -559,6 +550,16 @@ def _collectfile(self, path):
559
550
if not self .isinitpath (path ):
560
551
if ihook .pytest_ignore_collect (path = path , config = self .config ):
561
552
return ()
553
+
554
+ # Skip duplicate paths.
555
+ keepduplicates = self .config .getoption ("keepduplicates" )
556
+ if not keepduplicates :
557
+ duplicate_paths = self .config .pluginmanager ._duplicatepaths
558
+ if path in duplicate_paths :
559
+ return ()
560
+ else :
561
+ duplicate_paths .add (path )
562
+
562
563
return ihook .pytest_collect_file (path = path , parent = self )
563
564
564
565
def _recurse (self , path ):
Original file line number Diff line number Diff line change @@ -552,15 +552,6 @@ def isinitpath(self, path):
552
552
return path in self .session ._initialpaths
553
553
554
554
def collect (self ):
555
- # XXX: HACK!
556
- # Before starting to collect any files from this package we need
557
- # to cleanup the duplicate paths added by the session's collect().
558
- # Proper fix is to not track these as duplicates in the first place.
559
- for path in list (self .session .config .pluginmanager ._duplicatepaths ):
560
- # if path.parts()[:len(self.fspath.dirpath().parts())] == self.fspath.dirpath().parts():
561
- if path .dirname .startswith (self .name ):
562
- self .session .config .pluginmanager ._duplicatepaths .remove (path )
563
-
564
555
this_path = self .fspath .dirpath ()
565
556
init_module = this_path .join ("__init__.py" )
566
557
if init_module .check (file = 1 ) and path_matches_patterns (
Original file line number Diff line number Diff line change @@ -219,7 +219,7 @@ class TestY(TestX):
219
219
started = reprec .getcalls ("pytest_collectstart" )
220
220
finished = reprec .getreports ("pytest_collectreport" )
221
221
assert len (started ) == len (finished )
222
- assert len (started ) == 7 # XXX extra TopCollector
222
+ assert len (started ) == 8
223
223
colfail = [x for x in finished if x .failed ]
224
224
assert len (colfail ) == 1
225
225
You can’t perform that action at this time.
0 commit comments