Skip to content

Commit b46d42d

Browse files
committed
_getconftestmodules: avoid isfile()/dirpath()
Ref: pytest-dev#2206 (comment)
1 parent 8bced74 commit b46d42d

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
@@ -380,13 +380,13 @@ def _getconftestmodules(self, path):
380380
if self._noconftest:
381381
return []
382382

383-
if path.isfile():
384-
directory = path.dirpath()
385-
else:
386-
directory = path
387383
try:
388-
return self._path2confmods[directory]
384+
return self._path2confmods[path]
389385
except KeyError:
386+
if path.isfile():
387+
directory = path.dirpath()
388+
else:
389+
directory = path
390390
# XXX these days we may rather want to use config.rootdir
391391
# and allow users to opt into looking into the rootdir parent
392392
# directories instead of requiring to specify confcutdir
@@ -399,7 +399,7 @@ def _getconftestmodules(self, path):
399399
mod = self._importconftest(conftestpath)
400400
clist.append(mod)
401401

402-
self._path2confmods[directory] = clist
402+
self._path2confmods[path] = clist
403403
return clist
404404

405405
def _rget_with_confmod(self, name, path):

0 commit comments

Comments
 (0)