How to use the watchgod.arun_process function in watchgod

To help you get started, we’ve selected a few watchgod examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github samuelcolvin / watchgod / tests / test_run_process.py View on Github external
async def test_async_alive_terminates(mocker):
    mock_start_process = mocker.patch('watchgod.main._start_process')
    mock_start_process.return_value = FakeProcess()
    mock_kill = mocker.patch('watchgod.main.os.kill')
    f = Future()
    f.set_result(1)
    c = mocker.MagicMock(return_value=f)

    reloads = await arun_process('/x/y/async', object(), watcher_cls=FakeWatcher, callback=c, debounce=5, min_sleep=1)
    assert reloads == 1
    assert mock_start_process.call_count == 2
    assert mock_kill.call_count == 1
    assert c.call_count == 1
    c.assert_called_with({'x'})