@@ -214,7 +214,7 @@ def __init__(self):
214
214
self ._conftest_plugins = set ()
215
215
216
216
# state related to local conftest plugins
217
- self ._path2confmods = {}
217
+ self ._dirpath2confmods = {}
218
218
self ._conftestpath2mod = {}
219
219
self ._confcutdir = None
220
220
self ._noconftest = False
@@ -385,31 +385,29 @@ def _try_load_conftest(self, anchor):
385
385
if x .check (dir = 1 ):
386
386
self ._getconftestmodules (x )
387
387
388
+ @lru_cache (maxsize = 128 )
388
389
def _getconftestmodules (self , path ):
389
390
if self ._noconftest :
390
391
return []
391
392
392
- try :
393
- return self ._path2confmods [path ]
394
- except KeyError :
395
- if path .isfile ():
396
- directory = path .dirpath ()
397
- else :
398
- directory = path
399
- # XXX these days we may rather want to use config.rootdir
400
- # and allow users to opt into looking into the rootdir parent
401
- # directories instead of requiring to specify confcutdir
402
- clist = []
403
- for parent in directory .realpath ().parts ():
404
- if self ._confcutdir and self ._confcutdir .relto (parent ):
405
- continue
406
- conftestpath = parent .join ("conftest.py" )
407
- if conftestpath .isfile ():
408
- mod = self ._importconftest (conftestpath )
409
- clist .append (mod )
410
-
411
- self ._path2confmods [path ] = clist
412
- return clist
393
+ if path .isfile ():
394
+ directory = path .dirpath ()
395
+ else :
396
+ directory = path
397
+
398
+ # XXX these days we may rather want to use config.rootdir
399
+ # and allow users to opt into looking into the rootdir parent
400
+ # directories instead of requiring to specify confcutdir
401
+ clist = []
402
+ for parent in directory .realpath ().parts ():
403
+ if self ._confcutdir and self ._confcutdir .relto (parent ):
404
+ continue
405
+ conftestpath = parent .join ("conftest.py" )
406
+ if conftestpath .isfile ():
407
+ mod = self ._importconftest (conftestpath )
408
+ clist .append (mod )
409
+ self ._dirpath2confmods [directory ] = clist
410
+ return clist
413
411
414
412
def _rget_with_confmod (self , name , path ):
415
413
modules = self ._getconftestmodules (path )
@@ -450,8 +448,8 @@ def _importconftest(self, conftestpath):
450
448
self ._conftest_plugins .add (mod )
451
449
self ._conftestpath2mod [conftestpath ] = mod
452
450
dirpath = conftestpath .dirpath ()
453
- if dirpath in self ._path2confmods :
454
- for path , mods in self ._path2confmods .items ():
451
+ if dirpath in self ._dirpath2confmods :
452
+ for path , mods in self ._dirpath2confmods .items ():
455
453
if path and path .relto (dirpath ) or path == dirpath :
456
454
assert mod not in mods
457
455
mods .append (mod )
@@ -902,7 +900,6 @@ def _getini(self, name):
902
900
assert type is None
903
901
return value
904
902
905
- @lru_cache (maxsize = None )
906
903
def _getconftest_pathlist (self , name , path ):
907
904
try :
908
905
mod , relroots = self .pluginmanager ._rget_with_confmod (name , path )
0 commit comments