示例#1
0
    def _collectfile(
        self, path: py.path.local, handle_dupes: bool = True
    ) -> Sequence[nodes.Collector]:
        fspath = Path(path)
        assert (
            path.isfile()
        ), "{!r} is not a file (isdir={!r}, exists={!r}, islink={!r})".format(
            path, path.isdir(), path.exists(), path.islink()
        )
        ihook = self.gethookproxy(path)
        if not self.isinitpath(path):
            if ihook.pytest_ignore_collect(
                fspath=fspath, path=path, config=self.config
            ):
                return ()

        if handle_dupes:
            keepduplicates = self.config.getoption("keepduplicates")
            if not keepduplicates:
                duplicate_paths = self.config.pluginmanager._duplicatepaths
                if path in duplicate_paths:
                    return ()
                else:
                    duplicate_paths.add(path)

        return ihook.pytest_collect_file(fspath=fspath, path=path, parent=self)  # type: ignore[no-any-return]
示例#2
0
 def get_dir_from_path(path: py.path.local) -> py.path.local:
     if path.isdir():
         return path
     return py.path.local(path.dirname)