test_watchdog.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:landscape-client 作者: CanonicalLtd 项目源码 文件源码
def test_dont_write_pid_file_until_we_really_start(
            self, mock_watchdog, mock_daemonize, mock_reactor):
        """
        If the client can't be started because another client is still running,
        the client shouldn't be daemonized and the pid file shouldn't be
        written.
        """
        mock_watchdog().check_running.return_value = succeed([StubDaemon()])
        mock_reactor.crash.return_value = None
        self.log_helper.ignore_errors(
            "ERROR: The following daemons are already running: program-name")
        pid_file = self.makeFile()

        self.configuration.daemon = True
        self.configuration.pid_file = pid_file
        service = WatchDogService(self.configuration)

        service.startService()
        self.assertFalse(os.path.exists(pid_file))
        mock_daemonize.assert_not_called()
        mock_watchdog().check_running.assert_called_once_with()
        mock_watchdog().start.assert_not_called()
        mock_reactor.crash.assert_called_once_with()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号