@@ -214,7 +214,7 @@ def __init__(self):
214214 self ._conftest_plugins = set ()
215215
216216 # state related to local conftest plugins
217- self ._path2confmods = {}
217+ self ._dirpath2confmods = {}
218218 self ._conftestpath2mod = {}
219219 self ._confcutdir = None
220220 self ._noconftest = False
@@ -385,31 +385,29 @@ def _try_load_conftest(self, anchor):
385385 if x .check (dir = 1 ):
386386 self ._getconftestmodules (x )
387387
388+ @lru_cache (maxsize = 128 )
388389 def _getconftestmodules (self , path ):
389390 if self ._noconftest :
390391 return []
391392
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
413411
414412 def _rget_with_confmod (self , name , path ):
415413 modules = self ._getconftestmodules (path )
@@ -450,8 +448,8 @@ def _importconftest(self, conftestpath):
450448 self ._conftest_plugins .add (mod )
451449 self ._conftestpath2mod [conftestpath ] = mod
452450 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 ():
455453 if path and path .relto (dirpath ) or path == dirpath :
456454 assert mod not in mods
457455 mods .append (mod )
@@ -902,7 +900,6 @@ def _getini(self, name):
902900 assert type is None
903901 return value
904902
905- @lru_cache (maxsize = None )
906903 def _getconftest_pathlist (self , name , path ):
907904 try :
908905 mod , relroots = self .pluginmanager ._rget_with_confmod (name , path )
0 commit comments