|
| 1 | +import os |
1 | 2 | import textwrap
|
| 3 | +from pathlib import Path |
2 | 4 |
|
3 | 5 | import py
|
4 | 6 |
|
@@ -163,11 +165,12 @@ def test_setinitial_conftest_subdirs(testdir, name):
|
163 | 165 | subconftest = sub.ensure("conftest.py")
|
164 | 166 | conftest = PytestPluginManager()
|
165 | 167 | conftest_setinitial(conftest, [sub.dirpath()], confcutdir=testdir.tmpdir)
|
| 168 | + key = Path(str(subconftest)).resolve() |
166 | 169 | if name not in ("whatever", ".dotdir"):
|
167 |
| - assert subconftest in conftest._conftestpath2mod |
| 170 | + assert key in conftest._conftestpath2mod |
168 | 171 | assert len(conftest._conftestpath2mod) == 1
|
169 | 172 | else:
|
170 |
| - assert subconftest not in conftest._conftestpath2mod |
| 173 | + assert key not in conftest._conftestpath2mod |
171 | 174 | assert len(conftest._conftestpath2mod) == 0
|
172 | 175 |
|
173 | 176 |
|
@@ -275,6 +278,31 @@ def fixture():
|
275 | 278 | assert result.ret == ExitCode.OK
|
276 | 279 |
|
277 | 280 |
|
| 281 | +@pytest.mark.skipif( |
| 282 | + os.path.normcase("x") != os.path.normcase("X"), |
| 283 | + reason="only relevant for case insensitive file systems", |
| 284 | +) |
| 285 | +def test_conftest_badcase(testdir): |
| 286 | + """Check conftest.py loading when directory casing is wrong (#5792).""" |
| 287 | + testdir.tmpdir.mkdir("JenkinsRoot").mkdir("test") |
| 288 | + source = {"setup.py": "", "test/__init__.py": "", "test/conftest.py": ""} |
| 289 | + testdir.makepyfile(**{"JenkinsRoot/%s" % k: v for k, v in source.items()}) |
| 290 | + |
| 291 | + testdir.tmpdir.join("jenkinsroot/test").chdir() |
| 292 | + result = testdir.runpytest() |
| 293 | + assert result.ret == ExitCode.NO_TESTS_COLLECTED |
| 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 | + |
278 | 306 | def test_no_conftest(testdir):
|
279 | 307 | testdir.makeconftest("assert 0")
|
280 | 308 | result = testdir.runpytest("--noconftest")
|
|
0 commit comments