Skip to content

Commit b940999

Browse files
committed
Fix
1 parent d014857 commit b940999

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

src/_pytest/config/__init__.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
from _pytest.pathlib import safe_exists
6464
from _pytest.stash import Stash
6565
from _pytest.warning_types import PytestConfigWarning
66+
from _pytest.warning_types import PytestDeprecationWarning
6667
from _pytest.warning_types import warn_explicit_for
6768

6869
if 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, registration_name=normalized_conftestpath)
664+
self.consider_conftest(mod, registration_name=conftestpath_str)
666665
return mod
667666

668667
def _check_non_top_pytest_plugins(
@@ -743,18 +742,17 @@ def consider_pluginarg(self, arg: str) -> None:
743742
self.import_plugin(arg, consider_entry_points=True)
744743

745744
def consider_conftest(
746-
self, conftestmodule: types.ModuleType, registration_name: str | None = None
745+
self, conftestmodule: types.ModuleType, registration_name: Optional[str] = None
747746
) -> None:
748747
""":meta private:"""
749748
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,
757752
)
753+
# Keep Pytest < 8 previous behaviour
754+
registration_name = conftestmodule.__file__
755+
758756
self.register(conftestmodule, name=registration_name)
759757

760758
def consider_env(self) -> None:

testing/test_pluginmanager.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ def test_conftestpath_case_sensitivity(self, pytester: Pytester) -> None:
109109
that does not depend on the case of the input path if the filesystem is
110110
case-insensitive.
111111
"""
112-
113112
config = pytester.parseconfig()
114113
pytester.makepyfile(**{"tests/conftest.py": ""})
115114

@@ -399,7 +398,7 @@ def test_consider_conftest_deps(
399398
pytester.makepyfile("pytest_plugins='xyz'"), root=pytester.path
400399
)
401400
with pytest.raises(ImportError):
402-
pytestpm.consider_conftest(mod)
401+
pytestpm.consider_conftest(mod, registration_name="unused")
403402

404403

405404
class TestPytestPluginManagerBootstrapming:

0 commit comments

Comments
 (0)