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

Function pytest_ignore_collect

src/_pytest/main.py:437–472  ·  view source on GitHub ↗
(collection_path: Path, config: Config)

Source from the content-addressed store, hash-verified

435
436
437def pytest_ignore_collect(collection_path: Path, config: Config) -> bool | None:
438 if collection_path.name == "__pycache__":
439 return True
440
441 ignore_paths = config._getconftest_pathlist(
442 "collect_ignore", path=collection_path.parent
443 )
444 ignore_paths = ignore_paths or []
445 excludeopt = config.getoption("ignore")
446 if excludeopt:
447 ignore_paths.extend(absolutepath(x) for x in excludeopt)
448
449 if collection_path in ignore_paths:
450 return True
451
452 ignore_globs = config._getconftest_pathlist(
453 "collect_ignore_glob", path=collection_path.parent
454 )
455 ignore_globs = ignore_globs or []
456 excludeglobopt = config.getoption("ignore_glob")
457 if excludeglobopt:
458 ignore_globs.extend(absolutepath(x) for x in excludeglobopt)
459
460 if any(fnmatch.fnmatch(str(collection_path), str(glob)) for glob in ignore_globs):
461 return True
462
463 allow_in_venv = config.getoption("collect_in_virtualenv")
464 if not allow_in_venv and _in_venv(collection_path):
465 return True
466
467 if collection_path.is_dir():
468 norecursepatterns = config.getini("norecursedirs")
469 if any(fnmatch_ex(pat, collection_path) for pat in norecursepatterns):
470 return True
471
472 return None
473
474
475def pytest_collect_directory(

Callers

nothing calls this directly

Calls 7

absolutepathFunction · 0.90
fnmatch_exFunction · 0.90
_in_venvFunction · 0.85
_getconftest_pathlistMethod · 0.80
getoptionMethod · 0.80
fnmatchMethod · 0.45
getiniMethod · 0.45

Tested by

no test coverage detected