Beispiel #1
0
def test_daemonise(mock_fork, mock_chdir, mock_setsid, mock_umask, mock_atexit,
                   mock_getpid):
    daemon = Daemon('/fake/path.pid')
    m_open = mock.mock_open()
    with mock.patch('builtins.open', m_open, create=True):
        daemon.daemonize()
    assert mock_fork.called is True
    assert mock_chdir.called is True
    assert mock_setsid.called is True
    assert mock_umask.called is True
    assert mock_atexit.called is True
def test_daemonise():
    pfile = create_file("test.pid", 123)
    with mock.patch("blackhole.daemon.Daemon.fork") as mock_fork, mock.patch(
            "os.chdir") as mock_chdir, mock.patch(
                "os.setsid") as mock_setsid, mock.patch(
                    "os.umask") as mock_umask, mock.patch(
                        "atexit.register") as mock_atexit, mock.patch(
                            "os.getpid", return_value=123):
        daemon = Daemon(pfile)
        daemon.daemonize()
    assert mock_fork.called is True
    assert mock_chdir.called is True
    assert mock_setsid.called is True
    assert mock_umask.called is True
    assert mock_atexit.called is True
Beispiel #3
0
def test_daemonise():
    pfile = create_file('test.pid', 123)
    with mock.patch('blackhole.daemon.Daemon.fork') as mock_fork, \
        mock.patch('os.chdir') as mock_chdir, \
        mock.patch('os.setsid') as mock_setsid, \
        mock.patch('os.umask') as mock_umask, \
        mock.patch('atexit.register') as mock_atexit, \
            mock.patch('os.getpid', return_value=123):
        daemon = Daemon(pfile)
        daemon.daemonize()
    assert mock_fork.called is True
    assert mock_chdir.called is True
    assert mock_setsid.called is True
    assert mock_umask.called is True
    assert mock_atexit.called is True
Beispiel #4
0
def test_daemonise():
    pfile = create_file("test.pid", 123)
    with mock.patch("blackhole.daemon.Daemon.fork") as mock_fork, mock.patch(
        "os.chdir"
    ) as mock_chdir, mock.patch("os.setsid") as mock_setsid, mock.patch(
        "os.umask"
    ) as mock_umask, mock.patch(
        "atexit.register"
    ) as mock_atexit, mock.patch(
        "os.getpid", return_value=123
    ):
        daemon = Daemon(pfile)
        daemon.daemonize()
    assert mock_fork.called is True
    assert mock_chdir.called is True
    assert mock_setsid.called is True
    assert mock_umask.called is True
    assert mock_atexit.called is True