Exemplo n.º 1
0
def test_run():
    cfile = create_config(('listen=:9999, :::9999', 'workers=2', ))
    Config(cfile).load()
    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)
    with mock.patch('socket.socket.bind'), \
            mock.patch('blackhole.worker.Worker.start'):
        supervisor = Supervisor(loop)
        with mock.patch('asyncio.unix_events._UnixSelectorEventLoop.'
                        'run_forever'):
            supervisor.run()
        assert len(supervisor.workers) == 2
    supervisor.loop.stop()
Exemplo n.º 2
0
def test_run():
    cfile = create_config(("listen=:9999, :::9999", "workers=2"))
    Config(cfile).load()
    loop = asyncio.new_event_loop()
    with mock.patch("socket.socket.bind"), mock.patch(
        "blackhole.worker.Worker.start"
    ):
        supervisor = Supervisor(loop=loop)
        with mock.patch("{0}.run_forever".format(_LOOP)):
            supervisor.run()
        assert len(supervisor.workers) == 2
    loop.run_until_complete(loop.shutdown_asyncgens())
    loop.close()