12
12
13
13
import _pytest ._code
14
14
from _pytest import nodes
15
+ from _pytest .config import Config
15
16
from _pytest .config import directory_arg
16
17
from _pytest .config import hookimpl
17
18
from _pytest .config import UsageError
@@ -339,18 +340,6 @@ def pytest_collection_modifyitems(items, config):
339
340
items [:] = remaining
340
341
341
342
342
- class FSHookProxy :
343
- def __init__ (self , fspath , pm , remove_mods ):
344
- self .fspath = fspath
345
- self .pm = pm
346
- self .remove_mods = remove_mods
347
-
348
- def __getattr__ (self , name ):
349
- x = self .pm .subset_hook_caller (name , remove_plugins = self .remove_mods )
350
- self .__dict__ [name ] = x
351
- return x
352
-
353
-
354
343
class NoMatch (Exception ):
355
344
""" raised if matching cannot locate a matching names. """
356
345
@@ -381,7 +370,7 @@ class Session(nodes.FSCollector):
381
370
_setupstate = None # type: SetupState
382
371
_fixturemanager = None # type: FixtureManager
383
372
384
- def __init__ (self , config ) :
373
+ def __init__ (self , config : Config ) -> None :
385
374
nodes .FSCollector .__init__ (
386
375
self , config .rootdir , parent = None , config = config , session = self , nodeid = ""
387
376
)
@@ -390,16 +379,15 @@ def __init__(self, config):
390
379
self .shouldstop = False
391
380
self .shouldfail = False
392
381
self .trace = config .trace .root .get ("collection" )
393
- self ._norecursepatterns = config .getini ("norecursedirs" )
394
382
self .startdir = config .invocation_dir
395
- self ._initialpaths = frozenset ()
383
+ self ._initialpaths = frozenset () # type: ignore
396
384
# Keep track of any collected nodes in here, so we don't duplicate fixtures
397
- self ._node_cache = {}
385
+ self ._node_cache = {} # type: ignore
398
386
self ._bestrelpathcache = _bestrelpath_cache (
399
387
config .rootdir
400
388
) # type: Dict[str, str]
401
389
# Dirnames of pkgs with dunder-init files.
402
- self ._pkg_roots = {}
390
+ self ._pkg_roots = {} # type: ignore
403
391
404
392
self .config .pluginmanager .register (self , name = "session" )
405
393
@@ -440,20 +428,6 @@ def pytest_runtest_logreport(self, report):
440
428
def isinitpath (self , path ):
441
429
return path in self ._initialpaths
442
430
443
- def gethookproxy (self , fspath ):
444
- # check if we have the common case of running
445
- # hooks with all conftest.py files
446
- pm = self .config .pluginmanager
447
- my_conftestmodules = pm ._getconftestmodules (fspath )
448
- remove_mods = pm ._conftest_plugins .difference (my_conftestmodules )
449
- if remove_mods :
450
- # one or more conftests are not in use at this fspath
451
- proxy = FSHookProxy (fspath , pm , remove_mods )
452
- else :
453
- # all plugins are active for this fspath
454
- proxy = self .config .hook
455
- return proxy
456
-
457
431
def perform_collect (self , args = None , genitems = True ):
458
432
hook = self .config .hook
459
433
try :
@@ -616,19 +590,6 @@ def _collectfile(self, path, handle_dupes=True):
616
590
617
591
return ihook .pytest_collect_file (path = path , parent = self )
618
592
619
- def _recurse (self , dirpath : py .path .local ) -> bool :
620
- if dirpath .basename == "__pycache__" :
621
- return False
622
- ihook = self .gethookproxy (dirpath .dirpath ())
623
- if ihook .pytest_ignore_collect (path = dirpath , config = self .config ):
624
- return False
625
- for pat in self ._norecursepatterns :
626
- if dirpath .check (fnmatch = pat ):
627
- return False
628
- ihook = self .gethookproxy (dirpath )
629
- ihook .pytest_collect_directory (path = dirpath , parent = self )
630
- return True
631
-
632
593
@staticmethod
633
594
def _visit_filter (f ):
634
595
return f .check (file = 1 )
0 commit comments