Skip to content

_getconftestmodules: avoid isfile()/dirpath() #4224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/_pytest/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,13 +387,13 @@ def _getconftestmodules(self, path):
if self._noconftest:
return []

if path.isfile():
directory = path.dirpath()
else:
directory = path
try:
return self._path2confmods[directory]
return self._path2confmods[path]
except KeyError:
if path.isfile():
directory = path.dirpath()
else:
directory = path
# XXX these days we may rather want to use config.rootdir
# and allow users to opt into looking into the rootdir parent
# directories instead of requiring to specify confcutdir
Expand All @@ -406,7 +406,7 @@ def _getconftestmodules(self, path):
mod = self._importconftest(conftestpath)
clist.append(mod)

self._path2confmods[directory] = clist
self._path2confmods[path] = clist
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that with 1acb18b I've noticed that some other code might expect a dirpath in self._path2confmods - haven't checked if I broke this with the previous optimization already though.

return clist

def _rget_with_confmod(self, name, path):
Expand Down