@@ -1483,27 +1483,27 @@ def getfixtureinfo(
1483
1483
1484
1484
return FuncFixtureInfo (argnames , initialnames , names_closure , arg2fixturedefs )
1485
1485
1486
- def pytest_plugin_registered (self , plugin : _PluggyPlugin ) -> None :
1487
- nodeid = None
1488
- plugin_name = self .config .pluginmanager .get_name (plugin )
1489
-
1490
- # Construct the base nodeid which is later used to check
1491
- # what fixtures are visible for particular tests (as denoted
1492
- # by their test id).
1486
+ def pytest_plugin_registered (self , plugin : _PluggyPlugin , plugin_name : str ) -> None :
1487
+ # Fixtures defined in conftest plugins are only visible to within the
1488
+ # conftest's directory. This is unlike fixtures in non-conftest plugins
1489
+ # which have global visibility. So for conftests, construct the base
1490
+ # nodeid from the plugin name (which is the conftest path).
1493
1491
if plugin_name and plugin_name .endswith ("conftest.py" ):
1494
- # The plugin name is assumed to be equal to plugin.__file__
1495
- # for conftest plugins. The difference is that plugin_name
1496
- # has the correct capitalization on capital-insensitive
1497
- # systems (Windows ).
1498
- p = absolutepath (plugin_name )
1492
+ # Note: we explicitly do *not* use ` plugin.__file__` here -- The
1493
+ # difference is that plugin_name has the correct capitalization on
1494
+ # case-insensitive systems (Windows) and other normalization issues
1495
+ # (issue #11816 ).
1496
+ conftestpath = absolutepath (plugin_name )
1499
1497
try :
1500
- nodeid = str (p .parent .relative_to (self .config .rootpath ))
1498
+ nodeid = str (conftestpath .parent .relative_to (self .config .rootpath ))
1501
1499
except ValueError :
1502
1500
nodeid = ""
1503
1501
if nodeid == "." :
1504
1502
nodeid = ""
1505
1503
if os .sep != nodes .SEP :
1506
1504
nodeid = nodeid .replace (os .sep , nodes .SEP )
1505
+ else :
1506
+ nodeid = None
1507
1507
1508
1508
self .parsefactories (plugin , nodeid )
1509
1509
0 commit comments