diff --git a/changelog/5819.bugfix.rst b/changelog/5819.bugfix.rst new file mode 100644 index 00000000000..aa953429ad1 --- /dev/null +++ b/changelog/5819.bugfix.rst @@ -0,0 +1,2 @@ +Windows: Fix regression with conftest whose qualified name contains uppercase +characters (introduced by #5792). diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py index 0403b694737..d47ede20a25 100644 --- a/src/_pytest/pathlib.py +++ b/src/_pytest/pathlib.py @@ -11,7 +11,6 @@ from os.path import expanduser from os.path import expandvars from os.path import isabs -from os.path import normcase from os.path import sep from posixpath import sep as posix_sep @@ -343,4 +342,4 @@ def unique_path(path): This is needed only for ``py.path.local``; ``pathlib.Path`` handles this natively with ``resolve()``.""" - return type(path)(normcase(str(path.realpath()))) + return type(path)(Path(str(path)).resolve()) diff --git a/testing/test_conftest.py b/testing/test_conftest.py index 9888f5457f3..8395ab49511 100644 --- a/testing/test_conftest.py +++ b/testing/test_conftest.py @@ -292,6 +292,16 @@ def test_conftest_badcase(testdir): assert result.ret == ExitCode.NO_TESTS_COLLECTED +def test_conftest_uppercase(testdir): + """Check conftest.py loading when directory casing is wrong.""" + source = {"__init__.py": "", "Foo/conftest.py": "", "Foo/__init__.py": ""} + testdir.makepyfile(**source) + + testdir.tmpdir.chdir() + result = testdir.runpytest() + assert result.ret == ExitCode.NO_TESTS_COLLECTED + + def test_no_conftest(testdir): testdir.makeconftest("assert 0") result = testdir.runpytest("--noconftest")