MCPcopy
hub / github.com/pytest-dev/pytest / remove

Method remove

src/_pytest/_py/path.py:596–616  ·  src/_pytest/_py/path.py::LocalPath.remove

Remove a file or directory (or a directory tree if rec=1). if ignore_errors is True, errors while removing directories will be ignored.

(self, rec=1, ignore_errors=False)

Source from the content-addressed store, hash-verified

594 return error.checked_call(os.path.samefile, self.strpath, other)
595
596 def remove(self, rec=1, ignore_errors=False):
597 class="st">"""Remove a file or directory (or a directory tree if rec=1).
598 if ignore_errors is True, errors while removing directories will
599 be ignored.
600 class="st">"""
601 if self.check(dir=1, link=0):
602 if rec:
603 class="cm"># force remove of readonly files on windows
604 if iswin32:
605 self.chmod(0o700, rec=1)
606 import shutil
607
608 error.checked_call(
609 shutil.rmtree, self.strpath, ignore_errors=ignore_errors
610 )
611 else:
612 error.checked_call(os.rmdir, self.strpath)
613 else:
614 if iswin32:
615 self.chmod(0o700)
616 error.checked_call(os.remove, self.strpath)
617
618 def computehash(self, hashtype=class="st">"md5", chunksize=524288):
619 class="st">""class="st">"Return hexdigest of hashvalue for this file."class="st">""

Callers 15

moveMethod · 0.95
_check_exceptionsMethod · 0.80
undoFunction · 0.80
try_remove_lockfileMethod · 0.80
make_numbered_dirMethod · 0.80
_formatMethod · 0.80
_safe_reprMethod · 0.80
test_cache_makedirFunction · 0.80
test_copy_fileMethod · 0.80

Calls 3

checkMethod · 0.95
chmodMethod · 0.95
checked_callMethod · 0.80