def testCannotEraseFile(self):
        def failedUnlink(path):
            if '/contents0' in path:
                raise OSError(errno.EACCES, 'Permission denied', path)
            origUnlink(path)

        origUnlink = os.unlink
        os.unlink = failedUnlink

        try:
            foo = self.addComponent('foo:runtime', '1', '',[('/dir/contents0')])
            self.updatePkg('foo:runtime')
            # just so the erase doesn't try to erase the directory, add a file
            self.writeFile('%s/dir/foo' % self.rootDir, 'blah\n') 
            self.logFilter.add()
            try:
                self.erasePkg(self.rootDir, 'foo:runtime')
            except __HOLE__:
                pass
            else:
                assert 0
            self.logFilter.compare([
                    'error: /dir/contents0 could not be removed: '
                        'Permission denied', 
                    'error: a critical error occured -- reverting '
                        'filesystem changes'])
        finally:
            os.unlink = origUnlink
dataset/ETHPy150Open sassoftware/conary/conary_test/updatetest.py/UpdateTest.testCannotEraseFile