def test_removeSafelyRemoveFailsMoveSucceeds(self):
        def dummyRemove():
            """
            Raise an C{OSError} to emulate the branch of L{runner._removeSafely}
            in which path removal fails.
            """
            raise OSError()

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

        # Set up a trial directory with a _trial_marker
        directory = self.mktemp()
        os.mkdir(directory)
        dirPath = filepath.FilePath(directory)
        dirPath.child('_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
dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/trial/test/test_runner.py/RemoveSafelyTests.test_removeSafelyRemoveFailsMoveSucceeds