def test_removeSafelyRemoveFailsMoveSucceeds(self):
        """
        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.
        """
        def dummyRemove():
            """
            Raise an C{OSError} to emulate the branch of L{util._removeSafely}
            in which path removal fails.
            """
            raise OSError()

        # Patch stdout so we can check the print statements in _removeSafely
        out = NativeStringIO()
        self.patch(sys, 'stdout', out)

        # Set up a trial directory with a _trial_marker
        directory = self.mktemp().encode("utf-8")
        os.mkdir(directory)
        dirPath = filepath.FilePath(directory)
        dirPath.child(b'_trial_marker').touch()
        # Ensure that path.remove() raises an OSError
        dirPath.remove = dummyRemove

        util._removeSafely(dirPath)
        self.assertIn("could not remove FilePath", out.getvalue())

        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.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/trial/test/test_util.py