fix: Don't fail on create dir if an intermediate is missing

pull/26/head v2.6
Raphaël Vinot 2020-01-16 13:33:19 +01:00
parent c723f90611
commit a834cfea39
3 changed files with 3 additions and 3 deletions

View File

@ -326,7 +326,7 @@ class File(FileBase):
def make_tempdir(self) -> Path:
"""Make a temporary directory at self.tempdir_path."""
if not self.tempdir_path.exists():
self.tempdir_path.mkdir()
self.tempdir_path.mkdir(parents=True)
return self.tempdir_path
#######################

View File

@ -316,7 +316,7 @@ class KittenGroomerBase(object):
def safe_mkdir(self, directory_path: Path):
"""Make a directory if it does not exist."""
if not directory_path.exists():
os.makedirs(directory_path)
directory_path.mkdir(parents=True)
def list_all_files(self, directory_path: Path) -> Iterator[Path]:
"""Generator yielding path to all of the files in a directory tree."""

View File

@ -254,7 +254,7 @@ class TestFileBase:
file = FileBase(file_path, dst_path)
with mock.patch('kittengroomer.helpers.shutil.copy') as mock_copy:
file.safe_copy()
mock_copy.assert_called_once_with(str(file_path), str(dst_path))
mock_copy.assert_called_once_with(file_path, dst_path)
def test_safe_copy_removes_exec_perms(self):
"""`safe_copy` should create a file that doesn't have any of the