1
+ import os .path
1
2
import textwrap
2
3
3
4
import py
4
5
5
6
import pytest
6
7
from _pytest .config import PytestPluginManager
7
8
from _pytest .main import ExitCode
9
+ from _pytest .pathlib import unique_path
8
10
9
11
10
12
def ConftestWithSetinitial (path ):
@@ -141,11 +143,11 @@ def test_conftestcutdir(testdir):
141
143
# but we can still import a conftest directly
142
144
conftest ._importconftest (conf )
143
145
values = conftest ._getconftestmodules (conf .dirpath ())
144
- assert values [0 ].__file__ .startswith (str (conf ))
146
+ assert values [0 ].__file__ .startswith (str (unique_path ( conf ) ))
145
147
# and all sub paths get updated properly
146
148
values = conftest ._getconftestmodules (p )
147
149
assert len (values ) == 1
148
- assert values [0 ].__file__ .startswith (str (conf ))
150
+ assert values [0 ].__file__ .startswith (str (unique_path ( conf ) ))
149
151
150
152
151
153
def test_conftestcutdir_inplace_considered (testdir ):
@@ -154,7 +156,7 @@ def test_conftestcutdir_inplace_considered(testdir):
154
156
conftest_setinitial (conftest , [conf .dirpath ()], confcutdir = conf .dirpath ())
155
157
values = conftest ._getconftestmodules (conf .dirpath ())
156
158
assert len (values ) == 1
157
- assert values [0 ].__file__ .startswith (str (conf ))
159
+ assert values [0 ].__file__ .startswith (str (unique_path ( conf ) ))
158
160
159
161
160
162
@pytest .mark .parametrize ("name" , "test tests whatever .dotdir" .split ())
@@ -164,7 +166,7 @@ def test_setinitial_conftest_subdirs(testdir, name):
164
166
conftest = PytestPluginManager ()
165
167
conftest_setinitial (conftest , [sub .dirpath ()], confcutdir = testdir .tmpdir )
166
168
if name not in ("whatever" , ".dotdir" ):
167
- assert subconftest in conftest ._conftestpath2mod
169
+ assert unique_path ( subconftest ) in conftest ._conftestpath2mod
168
170
assert len (conftest ._conftestpath2mod ) == 1
169
171
else :
170
172
assert subconftest not in conftest ._conftestpath2mod
@@ -275,6 +277,21 @@ def fixture():
275
277
assert result .ret == ExitCode .OK
276
278
277
279
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
+
278
295
def test_no_conftest (testdir ):
279
296
testdir .makeconftest ("assert 0" )
280
297
result = testdir .runpytest ("--noconftest" )
0 commit comments