Skip to content

Commit cf5b544

Browse files
committed
Revert "Merge pull request #5792 from dynatrace-oss-contrib/bugfix/badcase"
This reverts commit 955e542, reversing changes made to 0215bcd. Will attempt a simpler approach
1 parent 73c5b7f commit cf5b544

File tree

4 files changed

+10
-42
lines changed

4 files changed

+10
-42
lines changed

AUTHORS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ Charnjit SiNGH (CCSJ)
5656
Chris Lamb
5757
Christian Boelsen
5858
Christian Fetzer
59-
Christian Neumüller
6059
Christian Theunert
6160
Christian Tismer
6261
Christopher Gilling

src/_pytest/config/__init__.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
from _pytest.compat import importlib_metadata
3131
from _pytest.outcomes import fail
3232
from _pytest.outcomes import Skipped
33-
from _pytest.pathlib import unique_path
3433
from _pytest.warning_types import PytestConfigWarning
3534

3635
hookimpl = HookimplMarker("pytest")
@@ -367,7 +366,7 @@ def _set_initial_conftests(self, namespace):
367366
"""
368367
current = py.path.local()
369368
self._confcutdir = (
370-
unique_path(current.join(namespace.confcutdir, abs=True))
369+
current.join(namespace.confcutdir, abs=True)
371370
if namespace.confcutdir
372371
else None
373372
)
@@ -406,18 +405,19 @@ def _getconftestmodules(self, path):
406405
else:
407406
directory = path
408407

409-
directory = unique_path(directory)
410-
411408
# XXX these days we may rather want to use config.rootdir
412409
# and allow users to opt into looking into the rootdir parent
413410
# directories instead of requiring to specify confcutdir
414411
clist = []
415-
for parent in directory.parts():
412+
for parent in directory.realpath().parts():
416413
if self._confcutdir and self._confcutdir.relto(parent):
417414
continue
418415
conftestpath = parent.join("conftest.py")
419416
if conftestpath.isfile():
420-
mod = self._importconftest(conftestpath)
417+
# Use realpath to avoid loading the same conftest twice
418+
# with build systems that create build directories containing
419+
# symlinks to actual files.
420+
mod = self._importconftest(conftestpath.realpath())
421421
clist.append(mod)
422422
self._dirpath2confmods[directory] = clist
423423
return clist
@@ -432,10 +432,6 @@ def _rget_with_confmod(self, name, path):
432432
raise KeyError(name)
433433

434434
def _importconftest(self, conftestpath):
435-
# Use realpath to avoid loading the same conftest twice
436-
# with build systems that create build directories containing
437-
# symlinks to actual files.
438-
conftestpath = unique_path(conftestpath)
439435
try:
440436
return self._conftestpath2mod[conftestpath]
441437
except KeyError:

src/_pytest/pathlib.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from os.path import expanduser
1212
from os.path import expandvars
1313
from os.path import isabs
14-
from os.path import normcase
1514
from os.path import sep
1615
from posixpath import sep as posix_sep
1716

@@ -335,12 +334,3 @@ def fnmatch_ex(pattern, path):
335334
def parts(s):
336335
parts = s.split(sep)
337336
return {sep.join(parts[: i + 1]) or sep for i in range(len(parts))}
338-
339-
340-
def unique_path(path):
341-
"""Returns a unique path in case-insensitive (but case-preserving) file
342-
systems such as Windows.
343-
344-
This is needed only for ``py.path.local``; ``pathlib.Path`` handles this
345-
natively with ``resolve()``."""
346-
return type(path)(normcase(str(path.realpath())))

testing/test_conftest.py

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import os.path
21
import textwrap
32

43
import py
54

65
import pytest
76
from _pytest.config import PytestPluginManager
87
from _pytest.main import ExitCode
9-
from _pytest.pathlib import unique_path
108

119

1210
def ConftestWithSetinitial(path):
@@ -143,11 +141,11 @@ def test_conftestcutdir(testdir):
143141
# but we can still import a conftest directly
144142
conftest._importconftest(conf)
145143
values = conftest._getconftestmodules(conf.dirpath())
146-
assert values[0].__file__.startswith(str(unique_path(conf)))
144+
assert values[0].__file__.startswith(str(conf))
147145
# and all sub paths get updated properly
148146
values = conftest._getconftestmodules(p)
149147
assert len(values) == 1
150-
assert values[0].__file__.startswith(str(unique_path(conf)))
148+
assert values[0].__file__.startswith(str(conf))
151149

152150

153151
def test_conftestcutdir_inplace_considered(testdir):
@@ -156,7 +154,7 @@ def test_conftestcutdir_inplace_considered(testdir):
156154
conftest_setinitial(conftest, [conf.dirpath()], confcutdir=conf.dirpath())
157155
values = conftest._getconftestmodules(conf.dirpath())
158156
assert len(values) == 1
159-
assert values[0].__file__.startswith(str(unique_path(conf)))
157+
assert values[0].__file__.startswith(str(conf))
160158

161159

162160
@pytest.mark.parametrize("name", "test tests whatever .dotdir".split())
@@ -166,7 +164,7 @@ def test_setinitial_conftest_subdirs(testdir, name):
166164
conftest = PytestPluginManager()
167165
conftest_setinitial(conftest, [sub.dirpath()], confcutdir=testdir.tmpdir)
168166
if name not in ("whatever", ".dotdir"):
169-
assert unique_path(subconftest) in conftest._conftestpath2mod
167+
assert subconftest in conftest._conftestpath2mod
170168
assert len(conftest._conftestpath2mod) == 1
171169
else:
172170
assert subconftest not in conftest._conftestpath2mod
@@ -277,21 +275,6 @@ def fixture():
277275
assert result.ret == ExitCode.OK
278276

279277

280-
@pytest.mark.skipif(
281-
os.path.normcase("x") != os.path.normcase("X"),
282-
reason="only relevant for case insensitive file systems",
283-
)
284-
def test_conftest_badcase(testdir):
285-
"""Check conftest.py loading when directory casing is wrong."""
286-
testdir.tmpdir.mkdir("JenkinsRoot").mkdir("test")
287-
source = {"setup.py": "", "test/__init__.py": "", "test/conftest.py": ""}
288-
testdir.makepyfile(**{"JenkinsRoot/%s" % k: v for k, v in source.items()})
289-
290-
testdir.tmpdir.join("jenkinsroot/test").chdir()
291-
result = testdir.runpytest()
292-
assert result.ret == ExitCode.NO_TESTS_COLLECTED
293-
294-
295278
def test_no_conftest(testdir):
296279
testdir.makeconftest("assert 0")
297280
result = testdir.runpytest("--noconftest")

0 commit comments

Comments
 (0)