From 63691f565666f312546c20b99975d8d9289744ee Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 24 Oct 2018 14:04:51 +0200 Subject: [PATCH] _getconftestmodules: avoid isfile()/dirpath() Ref: https://github.com/pytest-dev/pytest/issues/2206#issuecomment-432623646 --- src/_pytest/config/__init__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 443cf0889..8460562ab 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -387,13 +387,13 @@ class PytestPluginManager(PluginManager): 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 @@ -406,7 +406,7 @@ class PytestPluginManager(PluginManager): mod = self._importconftest(conftestpath) clist.append(mod) - self._path2confmods[directory] = clist + self._path2confmods[path] = clist return clist def _rget_with_confmod(self, name, path):