fix conftest related fixture visibility issue: when running with a

CWD outside a test package pytest would get fixture discovery wrong.
Thanks to Wolfgang Schnerring for figuring out a reproducable example.

--HG--
branch : conftest-nodeid
This commit is contained in:
holger krekel
2014-09-15 12:44:16 +02:00
parent 1a80487e71
commit b6dcfd4377
5 changed files with 46 additions and 3 deletions

View File

@@ -1611,10 +1611,15 @@ class FixtureManager:
except AttributeError:
pass
else:
# construct the base nodeid which is later used to check
# what fixtures are visible for particular tests (as denoted
# by their test id)
if p.basename.startswith("conftest.py"):
nodeid = p.dirpath().relto(self.session.fspath)
nodeid = self.session.fspath.bestrelpath(p.dirpath())
if p.sep != "/":
nodeid = nodeid.replace(p.sep, "/")
if nodeid == ".":
nodeid = ""
self.parsefactories(plugin, nodeid)
self._seenplugins.add(plugin)