예제 #1
0
def test_fork(mock_fork):
    pfile = create_file('test.pid', 123)
    daemon = Daemon(pfile)
    with pytest.raises(SystemExit) as err:
        daemon.fork()
    assert str(err.value) == '0'
    assert mock_fork.called is True
예제 #2
0
def test_fork_error():
    pfile = create_file('test.pid', 123)
    with mock.patch('atexit.register'):
        daemon = Daemon(pfile)
    with mock.patch('os.fork', side_effect=OSError) as mock_fork, \
            pytest.raises(DaemonException):
        daemon.fork()
    assert mock_fork.called is True
예제 #3
0
def test_fork_error():
    pfile = create_file("test.pid", 123)
    with mock.patch("atexit.register"):
        daemon = Daemon(pfile)
    with mock.patch(
            "os.fork",
            side_effect=OSError) as mock_fork, pytest.raises(DaemonException):
        daemon.fork()
    assert mock_fork.called is True
예제 #4
0
def test_fork():
    pfile = create_file("test.pid", 123)
    with mock.patch("atexit.register"):
        daemon = Daemon(pfile)
    with mock.patch("os.fork", return_value=9999) as mock_fork, mock.patch(
            "os._exit") as mock_exit:
        daemon.fork()
    assert mock_fork.called is True
    assert mock_exit.called is True
예제 #5
0
def test_fork():
    pfile = create_file('test.pid', 123)
    with mock.patch('atexit.register'):
        daemon = Daemon(pfile)
    with mock.patch('os.fork', return_value=9999) as mock_fork, \
            mock.patch('os._exit') as mock_exit:
        daemon.fork()
    assert mock_fork.called is True
    assert mock_exit.called is True
예제 #6
0
def test_fork():
    pfile = create_file("test.pid", 123)
    with mock.patch("atexit.register"):
        daemon = Daemon(pfile)
    with mock.patch("os.fork", return_value=9999) as mock_fork, mock.patch(
        "os._exit"
    ) as mock_exit:
        daemon.fork()
    assert mock_fork.called is True
    assert mock_exit.called is True
예제 #7
0
def test_fork_error(mock_fork):
    pfile = create_file('test.pid', 123)
    daemon = Daemon(pfile)
    with pytest.raises(DaemonException):
        daemon.fork()
    assert mock_fork.called is True