Skip to content

Commit 9cde67c

Browse files
authored
Merge pull request #4224 from blueyed/_getconftestmodules
_getconftestmodules: avoid isfile()/dirpath()
2 parents 56989a8 + 63691f5 commit 9cde67c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/_pytest/config/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,13 +387,13 @@ def _getconftestmodules(self, path):
387387
if self._noconftest:
388388
return []
389389

390-
if path.isfile():
391-
directory = path.dirpath()
392-
else:
393-
directory = path
394390
try:
395-
return self._path2confmods[directory]
391+
return self._path2confmods[path]
396392
except KeyError:
393+
if path.isfile():
394+
directory = path.dirpath()
395+
else:
396+
directory = path
397397
# XXX these days we may rather want to use config.rootdir
398398
# and allow users to opt into looking into the rootdir parent
399399
# directories instead of requiring to specify confcutdir
@@ -406,7 +406,7 @@ def _getconftestmodules(self, path):
406406
mod = self._importconftest(conftestpath)
407407
clist.append(mod)
408408

409-
self._path2confmods[directory] = clist
409+
self._path2confmods[path] = clist
410410
return clist
411411

412412
def _rget_with_confmod(self, name, path):

0 commit comments

Comments
 (0)