13
13
14
14
import py
15
15
import six
16
+ from _pytest .main import FSHookProxy
16
17
from _pytest .mark import MarkerError
17
18
from _pytest .config import hookimpl
18
19
19
20
import _pytest
20
- from _pytest .main import Session
21
21
import pluggy
22
22
from _pytest import fixtures
23
23
from _pytest import nodes
@@ -490,7 +490,7 @@ def setup(self):
490
490
self .addfinalizer (teardown_module )
491
491
492
492
493
- class Package (Session , Module ):
493
+ class Package (Module ):
494
494
495
495
def __init__ (self , fspath , parent = None , config = None , session = None , nodeid = None ):
496
496
session = parent .session
@@ -503,7 +503,38 @@ def __init__(self, fspath, parent=None, config=None, session=None, nodeid=None):
503
503
for path in list (session .config .pluginmanager ._duplicatepaths ):
504
504
if path .dirname == fspath .dirname and path != fspath :
505
505
session .config .pluginmanager ._duplicatepaths .remove (path )
506
- pass
506
+
507
+ def _recurse (self , path ):
508
+ ihook = self .gethookproxy (path .dirpath ())
509
+ if ihook .pytest_ignore_collect (path = path , config = self .config ):
510
+ return
511
+ for pat in self ._norecursepatterns :
512
+ if path .check (fnmatch = pat ):
513
+ return False
514
+ ihook = self .gethookproxy (path )
515
+ ihook .pytest_collect_directory (path = path , parent = self )
516
+ return True
517
+
518
+ def gethookproxy (self , fspath ):
519
+ # check if we have the common case of running
520
+ # hooks with all conftest.py filesall conftest.py
521
+ pm = self .config .pluginmanager
522
+ my_conftestmodules = pm ._getconftestmodules (fspath )
523
+ remove_mods = pm ._conftest_plugins .difference (my_conftestmodules )
524
+ if remove_mods :
525
+ # one or more conftests are not in use at this fspath
526
+ proxy = FSHookProxy (fspath , pm , remove_mods )
527
+ else :
528
+ # all plugis are active for this fspath
529
+ proxy = self .config .hook
530
+ return proxy
531
+
532
+ def _collectfile (self , path ):
533
+ ihook = self .gethookproxy (path )
534
+ if not self .isinitpath (path ):
535
+ if ihook .pytest_ignore_collect (path = path , config = self .config ):
536
+ return ()
537
+ return ihook .pytest_collect_file (path = path , parent = self )
507
538
508
539
def isinitpath (self , path ):
509
540
return path in self .session ._initialpaths
0 commit comments