def test_stop_process_dead(smart_caplog, mocker):
    mock_kill = mocker.patch('aiohttp_devtools.runserver.watch.os.kill')
    mocker.patch('aiohttp_devtools.runserver.watch.awatch')
    app_task = AppTask(MagicMock(), MagicMock())
    app_task._process = MagicMock()
    app_task._process.is_alive = MagicMock(return_value=False)
    app_task._process.exitcode = 123
    app_task._stop_dev_server()
    assert 'server process already dead, exit code: 123' in smart_caplog
    assert mock_kill.called is False
def test_stop_process_clean(mocker):
    mock_kill = mocker.patch('aiohttp_devtools.runserver.watch.os.kill')
    mocker.patch('aiohttp_devtools.runserver.watch.awatch')
    app_task = AppTask(MagicMock(), MagicMock())
    app_task._process = MagicMock()
    app_task._process.is_alive = MagicMock(return_value=True)
    app_task._process.pid = 321
    app_task._process.exitcode = 123
    app_task._stop_dev_server()
    assert mock_kill.called_once_with(321, 2)
Exemple #3
0
async def test_stop_process_dirty(mocker):
    mock_kill = mocker.patch('aiohttp_devtools.runserver.watch.os.kill')
    mocker.patch('aiohttp_devtools.runserver.watch.awatch')
    app_task = AppTask(MagicMock())
    process_mock = MagicMock()
    app_task._process = process_mock
    process_mock.is_alive = MagicMock(return_value=True)
    process_mock.pid = 321
    process_mock.exitcode = None
    app_task._stop_dev_server()
    assert mock_kill.call_args_list == [call(321, 2)]
    assert process_mock.kill.called_once()
def test_stop_process_dirty(mocker):
    mock_kill = mocker.patch('aiohttp_devtools.runserver.watch.os.kill')
    mocker.patch('aiohttp_devtools.runserver.watch.awatch')
    app_task = AppTask(MagicMock(), MagicMock())
    app_task._process = MagicMock()
    app_task._process.is_alive = MagicMock(return_value=True)
    app_task._process.pid = 321
    app_task._process.exitcode = None
    app_task._stop_dev_server()
    assert mock_kill.call_args_list == [
        call(321, 2),
        call(321, 9),
    ]