'When used as a context manager, a L{PIDFile} will replace the
underlying PIDFile rather than raising L{AlreadyRunningError} if the
contained PID file exists but refers to a non-running PID.'

@ifPlatformSupported
def test_contextManagerDoesntExist(self):

    pidFile = PIDFile(DummyFilePath())
    pidFile._write(1337)
    def kill(pid, signal):
        raise OSError(errno.ESRCH, 'No    such    process')
    self.patch(_pidfile, 'kill', kill)
    e = self.assertRaises(StalePIDFileError, pidFile.isRunning)
    self.assertEqual(str(e), 'PID    file    refers    to    non-existing    process')
    with pidFile:
        self.assertEqual(pidFile.read(), getpid())
