1
- import os . path
1
+ import os
2
2
import textwrap
3
+ from pathlib import Path
3
4
4
5
import py
5
6
6
7
import pytest
7
8
from _pytest .config import PytestPluginManager
8
9
from _pytest .main import ExitCode
9
- from _pytest .pathlib import unique_path
10
10
11
11
12
12
def ConftestWithSetinitial (path ):
@@ -143,11 +143,11 @@ def test_conftestcutdir(testdir):
143
143
# but we can still import a conftest directly
144
144
conftest ._importconftest (conf )
145
145
values = conftest ._getconftestmodules (conf .dirpath ())
146
- assert values [0 ].__file__ .startswith (str (unique_path ( conf ) ))
146
+ assert values [0 ].__file__ .startswith (str (conf ))
147
147
# and all sub paths get updated properly
148
148
values = conftest ._getconftestmodules (p )
149
149
assert len (values ) == 1
150
- assert values [0 ].__file__ .startswith (str (unique_path ( conf ) ))
150
+ assert values [0 ].__file__ .startswith (str (conf ))
151
151
152
152
153
153
def test_conftestcutdir_inplace_considered (testdir ):
@@ -156,7 +156,7 @@ def test_conftestcutdir_inplace_considered(testdir):
156
156
conftest_setinitial (conftest , [conf .dirpath ()], confcutdir = conf .dirpath ())
157
157
values = conftest ._getconftestmodules (conf .dirpath ())
158
158
assert len (values ) == 1
159
- assert values [0 ].__file__ .startswith (str (unique_path ( conf ) ))
159
+ assert values [0 ].__file__ .startswith (str (conf ))
160
160
161
161
162
162
@pytest .mark .parametrize ("name" , "test tests whatever .dotdir" .split ())
@@ -165,11 +165,12 @@ def test_setinitial_conftest_subdirs(testdir, name):
165
165
subconftest = sub .ensure ("conftest.py" )
166
166
conftest = PytestPluginManager ()
167
167
conftest_setinitial (conftest , [sub .dirpath ()], confcutdir = testdir .tmpdir )
168
+ key = Path (str (subconftest )).resolve ()
168
169
if name not in ("whatever" , ".dotdir" ):
169
- assert unique_path ( subconftest ) in conftest ._conftestpath2mod
170
+ assert key in conftest ._conftestpath2mod
170
171
assert len (conftest ._conftestpath2mod ) == 1
171
172
else :
172
- assert subconftest not in conftest ._conftestpath2mod
173
+ assert key not in conftest ._conftestpath2mod
173
174
assert len (conftest ._conftestpath2mod ) == 0
174
175
175
176
@@ -282,7 +283,7 @@ def fixture():
282
283
reason = "only relevant for case insensitive file systems" ,
283
284
)
284
285
def test_conftest_badcase (testdir ):
285
- """Check conftest.py loading when directory casing is wrong."""
286
+ """Check conftest.py loading when directory casing is wrong (#5792) ."""
286
287
testdir .tmpdir .mkdir ("JenkinsRoot" ).mkdir ("test" )
287
288
source = {"setup.py" : "" , "test/__init__.py" : "" , "test/conftest.py" : "" }
288
289
testdir .makepyfile (** {"JenkinsRoot/%s" % k : v for k , v in source .items ()})
@@ -292,6 +293,16 @@ def test_conftest_badcase(testdir):
292
293
assert result .ret == ExitCode .NO_TESTS_COLLECTED
293
294
294
295
296
+ def test_conftest_uppercase (testdir ):
297
+ """Check conftest.py whose qualified name contains uppercase characters (#5819)"""
298
+ source = {"__init__.py" : "" , "Foo/conftest.py" : "" , "Foo/__init__.py" : "" }
299
+ testdir .makepyfile (** source )
300
+
301
+ testdir .tmpdir .chdir ()
302
+ result = testdir .runpytest ()
303
+ assert result .ret == ExitCode .NO_TESTS_COLLECTED
304
+
305
+
295
306
def test_no_conftest (testdir ):
296
307
testdir .makeconftest ("assert 0" )
297
308
result = testdir .runpytest ("--noconftest" )
0 commit comments