Esempio n. 1
0
def pytest_ignore_collect(collection_path: Path,
                          config: Config) -> Optional[bool]:
    ignore_paths = config._getconftest_pathlist("collect_ignore",
                                                path=collection_path.parent,
                                                rootpath=config.rootpath)
    ignore_paths = ignore_paths or []
    excludeopt = config.getoption("ignore")
    if excludeopt:
        ignore_paths.extend(absolutepath(x) for x in excludeopt)

    if collection_path in ignore_paths:
        return True

    ignore_globs = config._getconftest_pathlist("collect_ignore_glob",
                                                path=collection_path.parent,
                                                rootpath=config.rootpath)
    ignore_globs = ignore_globs or []
    excludeglobopt = config.getoption("ignore_glob")
    if excludeglobopt:
        ignore_globs.extend(absolutepath(x) for x in excludeglobopt)

    if any(
            fnmatch.fnmatch(str(collection_path), str(glob))
            for glob in ignore_globs):
        return True

    allow_in_venv = config.getoption("collect_in_virtualenv")
    if not allow_in_venv and _in_venv(collection_path):
        return True
    return None
Esempio n. 2
0
def pytest_ignore_collect(path: py.path.local,
                          config: Config) -> Optional[bool]:
    ignore_paths = config._getconftest_pathlist("collect_ignore",
                                                path=path.dirpath())
    ignore_paths = ignore_paths or []
    excludeopt = config.getoption("ignore")
    if excludeopt:
        ignore_paths.extend([py.path.local(x) for x in excludeopt])

    if py.path.local(path) in ignore_paths or contains_ignorefile(Path(path)):
        return True

    ignore_globs = config._getconftest_pathlist("collect_ignore_glob",
                                                path=path.dirpath())
    ignore_globs = ignore_globs or []
    excludeglobopt = config.getoption("ignore_glob")
    if excludeglobopt:
        ignore_globs.extend([py.path.local(x) for x in excludeglobopt])

    if any(fnmatch.fnmatch(str(path), str(glob)) for glob in ignore_globs):
        return True

    allow_in_venv = config.getoption("collect_in_virtualenv")
    if not allow_in_venv and _in_venv(path):
        return True
    return None