def _copy2_ignoring_special_files(src, dest): # type: (str, str) -> None """Copying special files is not supported, but as a convenience to users we skip errors copying them. This supports tools that may create e.g. socket files in the project source directory. """ try: copy2_fixed(src, dest) except shutil.SpecialFileError as e: # SpecialFileError may be raised due to either the source or # destination. If the destination was the cause then we would actually # care, but since the destination directory is deleted prior to # copy we ignore all of them assuming it is caused by the source. logger.warning( "Ignoring special file error '%s' encountered copying %s to %s.", str(e), path_to_display(src), path_to_display(dest), )
def test_copy2_fixed_raises_appropriate_errors(create, error_type, tmpdir): src = tmpdir.joinpath("src") create(src) dest = tmpdir.joinpath("dest") with pytest.raises(error_type): copy2_fixed(src, dest) assert not dest.exists()
def test_copy2_fixed_raises_appropriate_errors(create: Callable[[str], None], error_type: Type[Exception], tmpdir: Path) -> None: src = tmpdir.joinpath("src") create(src) dest = tmpdir.joinpath("dest") with pytest.raises(error_type): copy2_fixed(src, dest) assert not dest.exists()