'Should raise error if PID file is not locked.'

def test_raises_error_if_pidfile_not_locked(self):

    set_runner_scenario(self, 'simple')
    instance = self.test_instance
    self.mock_runner_lock.is_locked.mock_returns = False
    self.mock_runner_lock.i_am_locking.mock_returns = False
    self.mock_runner_lock.read_pid.mock_returns = self.scenario['pidlockfile_scenario']['pidfile_pid']
    pidfile_path = self.scenario['pidfile_path']
    expect_error = runner.DaemonRunnerStopFailureError
    expect_message_content = pidfile_path
    try:
        instance.do_action()
    except expect_error as exc:
        pass
    else:
        raise self.failureException(('Failed    to    raise    ' + expect_error.__name__))
    scaffold.mock_restore()
    self.failUnlessIn(exc.message, expect_message_content)
