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

Function pytest_addoption

src/_pytest/cacheprovider.py:436–491  ·  view source on GitHub ↗
(parser: Parser)

Source from the content-addressed store, hash-verified

434
435
436def pytest_addoption(parser: Parser) -> None:
437 group = parser.getgroup("general")
438 group.addoption(
439 "--lf",
440 "--last-failed",
441 action="store_true",
442 dest="lf",
443 help="rerun only the tests that failed "
444 "at the last run (or all if none failed)",
445 )
446 group.addoption(
447 "--ff",
448 "--failed-first",
449 action="store_true",
450 dest="failedfirst",
451 help="run all tests, but run the last failures first.\n"
452 "This may re-order tests and thus lead to "
453 "repeated fixture setup/teardown.",
454 )
455 group.addoption(
456 "--nf",
457 "--new-first",
458 action="store_true",
459 dest="newfirst",
460 help="run tests from new files first, then the rest of the tests "
461 "sorted by file mtime",
462 )
463 group.addoption(
464 "--cache-show",
465 action="append",
466 nargs="?",
467 dest="cacheshow",
468 help=(
469 "show cache contents, don't perform collection or tests. "
470 "Optional argument: glob (default: '*')."
471 ),
472 )
473 group.addoption(
474 "--cache-clear",
475 action="store_true",
476 dest="cacheclear",
477 help="remove all cache contents at start of test run.",
478 )
479 cache_dir_default = ".pytest_cache"
480 if "TOX_ENV_DIR" in os.environ:
481 cache_dir_default = os.path.join(os.environ["TOX_ENV_DIR"], cache_dir_default)
482 parser.addini("cache_dir", default=cache_dir_default, help="cache directory path.")
483 group.addoption(
484 "--lfnf",
485 "--last-failed-no-failures",
486 action="store",
487 dest="last_failed_no_failures",
488 choices=("all", "none"),
489 default="all",
490 help="which tests to run with no previously (known) failures.",
491 )
492
493

Callers

nothing calls this directly

Calls 3

getgroupMethod · 0.80
addiniMethod · 0.80
addoptionMethod · 0.45

Tested by

no test coverage detected