avoid using __file__ in pytest_plugin_registered as can be wrong on Windows
This commit is contained in:
parent
a6708b9254
commit
6e9f566d79
|
@ -1485,23 +1485,25 @@ class FixtureManager:
|
||||||
|
|
||||||
def pytest_plugin_registered(self, plugin: _PluggyPlugin) -> None:
|
def pytest_plugin_registered(self, plugin: _PluggyPlugin) -> None:
|
||||||
nodeid = None
|
nodeid = None
|
||||||
try:
|
plugin_name = self.config.pluginmanager.get_name(plugin)
|
||||||
p = absolutepath(plugin.__file__) # type: ignore[attr-defined]
|
|
||||||
except AttributeError:
|
# Construct the base nodeid which is later used to check
|
||||||
pass
|
# what fixtures are visible for particular tests (as denoted
|
||||||
else:
|
# by their test id).
|
||||||
# Construct the base nodeid which is later used to check
|
if plugin_name and plugin_name.endswith("conftest.py"):
|
||||||
# what fixtures are visible for particular tests (as denoted
|
# The plugin name is assumed to be equal to plugin.__file__
|
||||||
# by their test id).
|
# for conftest plugins. The difference is that plugin_name
|
||||||
if p.name == "conftest.py":
|
# has the correct capitalization on capital-insensitive
|
||||||
try:
|
# systems (Windows).
|
||||||
nodeid = str(p.parent.relative_to(self.config.rootpath))
|
p = absolutepath(plugin_name)
|
||||||
except ValueError:
|
try:
|
||||||
nodeid = ""
|
nodeid = str(p.parent.relative_to(self.config.rootpath))
|
||||||
if nodeid == ".":
|
except ValueError:
|
||||||
nodeid = ""
|
nodeid = ""
|
||||||
if os.sep != nodes.SEP:
|
if nodeid == ".":
|
||||||
nodeid = nodeid.replace(os.sep, nodes.SEP)
|
nodeid = ""
|
||||||
|
if os.sep != nodes.SEP:
|
||||||
|
nodeid = nodeid.replace(os.sep, nodes.SEP)
|
||||||
|
|
||||||
self.parsefactories(plugin, nodeid)
|
self.parsefactories(plugin, nodeid)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue