6363from _pytest .pathlib import safe_exists
6464from _pytest .stash import Stash
6565from _pytest .warning_types import PytestConfigWarning
66+ from _pytest .warning_types import PytestDeprecationWarning
6667from _pytest .warning_types import warn_explicit_for
6768
6869if TYPE_CHECKING :
@@ -634,10 +635,8 @@ def _rget_with_confmod(
634635 def _importconftest (
635636 self , conftestpath : Path , importmode : Union [str , ImportMode ], rootpath : Path
636637 ) -> types .ModuleType :
637- # Avoid inconsistent path issues on Windows, see
638- # https://github.com/pytest-dev/pytest/issues/9765
639- normalized_conftestpath = os .path .normcase (conftestpath )
640- existing = self .get_plugin (normalized_conftestpath )
638+ conftestpath_str = str (conftestpath )
639+ existing = self .get_plugin (conftestpath_str )
641640 if existing is not None :
642641 return cast (types .ModuleType , existing )
643642
@@ -662,7 +661,7 @@ def _importconftest(
662661 assert mod not in mods
663662 mods .append (mod )
664663 self .trace (f"loading conftestmodule { mod !r} " )
665- self .consider_conftest (mod )
664+ self .consider_conftest (mod , registration_name = conftestpath_str )
666665 return mod
667666
668667 def _check_non_top_pytest_plugins (
@@ -742,13 +741,19 @@ def consider_pluginarg(self, arg: str) -> None:
742741 del self ._name2plugin ["pytest_" + name ]
743742 self .import_plugin (arg , consider_entry_points = True )
744743
745- def consider_conftest (self , conftestmodule : types .ModuleType ) -> None :
744+ def consider_conftest (
745+ self , conftestmodule : types .ModuleType , registration_name : Optional [str ] = None
746+ ) -> None :
746747 """:meta private:"""
747- name = conftestmodule .__file__
748- # Avoid inconsistent path issues on Windows, see
749- # https://github.com/pytest-dev/pytest/issues/9765
750- normalized_name = name if name is None else os .path .normcase (name )
751- self .register (conftestmodule , name = normalized_name )
748+ if registration_name is None :
749+ warnings .warn (
750+ "'consider_conftest' was called with registration_name=None, this will become an error in the future'" ,
751+ PytestDeprecationWarning ,
752+ )
753+ # Keep Pytest < 8 previous behaviour
754+ registration_name = conftestmodule .__file__
755+
756+ self .register (conftestmodule , name = registration_name )
752757
753758 def consider_env (self ) -> None :
754759 """:meta private:"""
0 commit comments