'If an L{OSError} is raised while removing a path in
L{util._removeSafely}, an attempt is made to move the path to a new
name. If that attempt fails, the L{OSError} is re-raised.'

def test_removeSafelyRemoveFailsMoveFails(self):

    def dummyRemove():
        '\n                                                Raise    an    C{OSError}    to    emulate    the    branch    of    L{util._removeSafely}\n                                                in    which    path    removal    fails.\n                                                '
        raise OSError('path    removal    failed')
    def dummyMoveTo(path):
        '\n                                                Raise    an    C{OSError}    to    emulate    the    branch    of    L{util._removeSafely}\n                                                in    which    path    movement    fails.\n                                                '
        raise OSError('path    movement    failed')
    out = NativeStringIO()
    self.patch(sys, 'stdout', out)
    directory = self.mktemp().encode('utf-8')
    os.mkdir(directory)
    dirPath = filepath.FilePath(directory)
    dirPath.child('_trial_marker').touch()
    dirPath.remove = dummyRemove
    dirPath.moveTo = dummyMoveTo
    error = self.assertRaises(OSError, util._removeSafely, dirPath)
    self.assertEqual(str(error), 'path    movement    failed')
    self.assertIn('could    not    remove    FilePath', out.getvalue())
