63
63
from _pytest .pathlib import safe_exists
64
64
from _pytest .stash import Stash
65
65
from _pytest .warning_types import PytestConfigWarning
66
+ from _pytest .warning_types import PytestDeprecationWarning
66
67
from _pytest .warning_types import warn_explicit_for
67
68
68
69
if TYPE_CHECKING :
@@ -634,10 +635,8 @@ def _rget_with_confmod(
634
635
def _importconftest (
635
636
self , conftestpath : Path , importmode : Union [str , ImportMode ], rootpath : Path
636
637
) -> 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 )
641
640
if existing is not None :
642
641
return cast (types .ModuleType , existing )
643
642
@@ -662,7 +661,7 @@ def _importconftest(
662
661
assert mod not in mods
663
662
mods .append (mod )
664
663
self .trace (f"loading conftestmodule { mod !r} " )
665
- self .consider_conftest (mod )
664
+ self .consider_conftest (mod , registration_name = conftestpath_str )
666
665
return mod
667
666
668
667
def _check_non_top_pytest_plugins (
@@ -742,13 +741,19 @@ def consider_pluginarg(self, arg: str) -> None:
742
741
del self ._name2plugin ["pytest_" + name ]
743
742
self .import_plugin (arg , consider_entry_points = True )
744
743
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 :
746
747
""":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 )
752
757
753
758
def consider_env (self ) -> None :
754
759
""":meta private:"""
0 commit comments