MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_module_full_path_without_drive

Function test_module_full_path_without_drive

testing/test_main.py:205–241  ·  view source on GitHub ↗

Collect and run test using full path except for the drive letter (#7628). Passing a full path without a drive letter would trigger a bug in legacy_path where it would keep the full path without the drive letter around, instead of resolving to the full path, resulting in fixtures node id

(pytester: Pytester)

Source from the content-addressed store, hash-verified

203
204
205def test_module_full_path_without_drive(pytester: Pytester) -> None:
206 """Collect and run test using full path except for the drive letter (#7628).
207
208 Passing a full path without a drive letter would trigger a bug in legacy_path
209 where it would keep the full path without the drive letter around, instead of resolving
210 to the full path, resulting in fixtures node ids not matching against test node ids correctly.
211 """
212 pytester.makepyfile(
213 **{
214 "project/conftest.py": """
215 import pytest
216 @pytest.fixture
217 def fix(): return 1
218 """,
219 }
220 )
221
222 pytester.makepyfile(
223 **{
224 "project/tests/dummy_test.py": """
225 def test(fix):
226 assert fix == 1
227 """
228 }
229 )
230 fn = pytester.path.joinpath("project/tests/dummy_test.py")
231 assert fn.is_file()
232
233 drive, path = os.path.splitdrive(str(fn))
234
235 result = pytester.runpytest(path, "-v")
236 result.stdout.fnmatch_lines(
237 [
238 os.path.join("project", "tests", "dummy_test.py") + "::test PASSED *",
239 "* 1 passed in *",
240 ]
241 )

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected