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 , registration_name = normalized_conftestpath )
664
+ self .consider_conftest (mod , registration_name = conftestpath_str )
666
665
return mod
667
666
668
667
def _check_non_top_pytest_plugins (
@@ -743,18 +742,17 @@ def consider_pluginarg(self, arg: str) -> None:
743
742
self .import_plugin (arg , consider_entry_points = True )
744
743
745
744
def consider_conftest (
746
- self , conftestmodule : types .ModuleType , registration_name : str | None = None
745
+ self , conftestmodule : types .ModuleType , registration_name : Optional [ str ] = None
747
746
) -> None :
748
747
""":meta private:"""
749
748
if registration_name is None :
750
- # Avoid inconsistent path issues on Windows, see
751
- # https://github.com/pytest-dev/pytest/issues/9765
752
- registration_name = conftestmodule .__file__
753
- registration_name = (
754
- registration_name
755
- if registration_name is None
756
- else os .path .normcase (registration_name )
749
+ warnings .warn (
750
+ "'consider_conftest' was called with registration_name=None, this will become an error in the future'" ,
751
+ PytestDeprecationWarning ,
757
752
)
753
+ # Keep Pytest < 8 previous behaviour
754
+ registration_name = conftestmodule .__file__
755
+
758
756
self .register (conftestmodule , name = registration_name )
759
757
760
758
def consider_env (self ) -> None :
0 commit comments