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

Function copytree

src/_pytest/pathlib.py:711–724  ·  view source on GitHub ↗

Recursively copy a source directory to target.

(source: Path, target: Path)

Source from the content-addressed store, hash-verified

709# Originates from py. path.local.copy(), with siginficant trims and adjustments.
710# TODO(py38): Replace with shutil.copytree(..., symlinks=True, dirs_exist_ok=True)
711def copytree(source: Path, target: Path) -> None:
712 """Recursively copy a source directory to target."""
713 assert source.is_dir()
714 for entry in visit(source, recurse=lambda entry: not entry.is_symlink()):
715 x = Path(entry)
716 relpath = x.relative_to(source)
717 newx = target / relpath
718 newx.parent.mkdir(exist_ok=True)
719 if x.is_symlink():
720 newx.symlink_to(os.readlink(x))
721 elif x.is_file():
722 shutil.copyfile(x, newx)
723 elif x.is_dir():
724 newx.mkdir(exist_ok=True)

Callers 1

copy_exampleMethod · 0.90

Calls 2

visitFunction · 0.85
mkdirMethod · 0.45

Tested by 1

copy_exampleMethod · 0.72