def test_delete_file_doesnt_exist(self): """ Tests that deleting when the file doesn't exist does *not* throw an error. """ # Setup self.assertTrue(not os.path.exists(TEST_REPO_FILENAME)) # Test repo_file = RepoFile(TEST_REPO_FILENAME) repo_file.delete()
def test_delete_repofile(self): """ Tests that deleting a RepoFile correctly deletes the file on disk. """ # Setup self.assertTrue(not os.path.exists(TEST_REPO_FILENAME)) repo_file = RepoFile(TEST_REPO_FILENAME) repo_file.save() self.assertTrue(os.path.exists(TEST_REPO_FILENAME)) # Test repo_file.delete() # Verify self.assertTrue(not os.path.exists(TEST_REPO_FILENAME))
def delete_repo_file(repo_filename, lock=None): """ Delete the repo file. @param repo_filename: full path to the location of the repo file which will be deleted; if this file does not exist this call has no effect @type repo_filename: string @param lock: if the default lock is unacceptable, it may be overridden in this variable @type lock: L{Lock} """ if not lock: lock = Lock(LOCK_FILE) lock.acquire() try: repo_file = RepoFile(repo_filename) repo_file.delete() finally: lock.release()