MCPcopy
hub / github.com/pytest-dev/pytest / test_rootdir_option_arg

Function test_rootdir_option_arg

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

Source from the content-addressed store, hash-verified

392
393@pytest.mark.parametrize("path", ["root", "{relative}/root", "{environment}/root"])
394def test_rootdir_option_arg(
395 pytester: Pytester, monkeypatch: MonkeyPatch, path: str
396) -> None:
397 monkeypatch.setenv("PY_ROOTDIR_PATH", str(pytester.path))
398 path = path.format(relative=str(pytester.path), environment="$PY_ROOTDIR_PATH")
399
400 rootdir = pytester.path / "root" / "tests"
401 rootdir.mkdir(parents=True)
402 pytester.makepyfile(
403 """
404 import os
405 def test_one():
406 assert 1
407 """
408 )
409
410 result = pytester.runpytest(f"--rootdir={path}")
411 result.stdout.fnmatch_lines(
412 [
413 f"*rootdir: {pytester.path}/root",
414 "root/test_rootdir_option_arg.py *",
415 "*1 passed*",
416 ]
417 )
418
419
420def 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