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

Function test_rootdir_option_arg

testing/test_session.py:339–362  ·  view source on GitHub ↗
(
    pytester: Pytester, monkeypatch: MonkeyPatch, path: str
)

Source from the content-addressed store, hash-verified

337
338@pytest.mark.parametrize("path", ["root", "{relative}/root", "{environment}/root"])
339def test_rootdir_option_arg(
340 pytester: Pytester, monkeypatch: MonkeyPatch, path: str
341) -> None:
342 monkeypatch.setenv("PY_ROOTDIR_PATH", str(pytester.path))
343 path = path.format(relative=str(pytester.path), environment="$PY_ROOTDIR_PATH")
344
345 rootdir = pytester.path / "root" / "tests"
346 rootdir.mkdir(parents=True)
347 pytester.makepyfile(
348 """
349 import os
350 def test_one():
351 assert 1
352 """
353 )
354
355 result = pytester.runpytest(f"--rootdir={path}")
356 result.stdout.fnmatch_lines(
357 [
358 f"*rootdir: {pytester.path}/root",
359 "root/test_rootdir_option_arg.py *",
360 "*1 passed*",
361 ]
362 )
363
364
365def test_rootdir_wrong_option_arg(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 6

setenvMethod · 0.80
fnmatch_linesMethod · 0.80
formatMethod · 0.45
mkdirMethod · 0.45
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected