3
3
import py
4
4
5
5
import pytest
6
- from _pytest .config import PytestPluginManager
6
+ from _pytest .config import PytestPluginManager , _uniquepath
7
7
from _pytest .main import ExitCode
8
+ import os .path
8
9
9
10
10
11
def ConftestWithSetinitial (path ):
@@ -141,11 +142,11 @@ def test_conftestcutdir(testdir):
141
142
# but we can still import a conftest directly
142
143
conftest ._importconftest (conf )
143
144
values = conftest ._getconftestmodules (conf .dirpath ())
144
- assert values [0 ].__file__ .startswith (str (conf ))
145
+ assert values [0 ].__file__ .startswith (str (_uniquepath ( conf ) ))
145
146
# and all sub paths get updated properly
146
147
values = conftest ._getconftestmodules (p )
147
148
assert len (values ) == 1
148
- assert values [0 ].__file__ .startswith (str (conf ))
149
+ assert values [0 ].__file__ .startswith (str (_uniquepath ( conf ) ))
149
150
150
151
151
152
def test_conftestcutdir_inplace_considered (testdir ):
@@ -154,7 +155,7 @@ def test_conftestcutdir_inplace_considered(testdir):
154
155
conftest_setinitial (conftest , [conf .dirpath ()], confcutdir = conf .dirpath ())
155
156
values = conftest ._getconftestmodules (conf .dirpath ())
156
157
assert len (values ) == 1
157
- assert values [0 ].__file__ .startswith (str (conf ))
158
+ assert values [0 ].__file__ .startswith (str (_uniquepath ( conf ) ))
158
159
159
160
160
161
@pytest .mark .parametrize ("name" , "test tests whatever .dotdir" .split ())
@@ -164,7 +165,7 @@ def test_setinitial_conftest_subdirs(testdir, name):
164
165
conftest = PytestPluginManager ()
165
166
conftest_setinitial (conftest , [sub .dirpath ()], confcutdir = testdir .tmpdir )
166
167
if name not in ("whatever" , ".dotdir" ):
167
- assert subconftest in conftest ._conftestpath2mod
168
+ assert _uniquepath ( subconftest ) in conftest ._conftestpath2mod
168
169
assert len (conftest ._conftestpath2mod ) == 1
169
170
else :
170
171
assert subconftest not in conftest ._conftestpath2mod
@@ -274,6 +275,24 @@ def fixture():
274
275
result .stdout .fnmatch_lines (["*conftest_loaded*" , "PASSED" ])
275
276
assert result .ret == ExitCode .OK
276
277
278
+ @pytest .mark .skipif (
279
+ os .path .normcase ('x' ) != os .path .normcase ('X' ),
280
+ reason = "only relevant for case insensitive file systems" ,
281
+ )
282
+ def test_conftest_badcase (testdir ):
283
+ """Check conftest.py loading when directory casing is wrong."""
284
+ testdir .tmpdir .mkdir ("JenkinsRoot" ).mkdir ("test" )
285
+ source = {
286
+ "setup.py" : "" ,
287
+ "test/__init__.py" : "" ,
288
+ "test/conftest.py" : ""
289
+ }
290
+ testdir .makepyfile (** {"JenkinsRoot/%s" % k : v for k , v in source .items ()})
291
+
292
+ testdir .tmpdir .join ("jenkinsroot/test" ).chdir ()
293
+ result = testdir .runpytest ()
294
+ assert result .ret == ExitCode .NO_TESTS_COLLECTED
295
+
277
296
278
297
def test_no_conftest (testdir ):
279
298
testdir .makeconftest ("assert 0" )
0 commit comments