def test_remove_file_force(self): """ Test removing a read-only file forcefully. """ dpath = self.__create_dir() fpath = os.path.join(dpath, "test") # Make the file read-only util.chmod(fpath, stat.S_IEXEC | stat.S_IREAD, recursive=True) util.remove_file(fpath, force=True) self.assertNot(os.path.exists(fpath))
def test_remove_file(self): dpath = self._get_tempdir() fpath = util.create_file(os.path.join(dpath, "test")) if util.get_os()[0] == Os_Windows: util.chmod(fpath, 0) else: util.chmod(dpath, 0) self.assertRaises(util.PermissionsError, util.remove_file, fpath) if util.get_os()[0] == Os_Windows: util.chmod(fpath, 0700) else: util.chmod(dpath, 0700) util.remove_file(fpath) self.assertNot(os.path.exists(fpath))