Exemple #1
0
def test_stop_runtime_exception():
    with mock.patch('blackhole.worker.Worker.start') as mock_start, \
            mock.patch('os.kill', side_effect=ProcessLookupError):
        w = Worker([], [])
        w.chat_task = mock.Mock()
        w.heartbeat_task = mock.Mock()
        w.rtransport = mock.Mock()
        w.wtransport = mock.Mock()
        w.pid = 123
        w.stop()
    assert mock_start.called is True
Exemple #2
0
def test_stop():
    with mock.patch('blackhole.worker.Worker.start') as mock_start, \
            mock.patch('os.kill') as mock_kill:
        w = Worker([], [])
        w.chat_task = mock.Mock()
        w.heartbeat_task = mock.Mock()
        w.rtransport = mock.Mock()
        w.wtransport = mock.Mock()
        w.pid = 123
        w.stop()
    assert mock_start.called is True
    assert mock_kill.called is True