aiohttp.test_utils.loop_context

Here are the examples of the python api aiohttp.test_utils.loop_context taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

4 Examples 7

Example 1

Project: aiohttp Source File: test_test_utils.py
def test_full_server_scenario():
    with loop_context() as loop:
        app = _create_example_app(loop)
        with _TestClient(app) as client:

            @asyncio.coroutine
            def test_get_route():
                nonlocal client
                resp = yield from client.request("GET", "/")
                assert resp.status == 200
                text = yield from resp.text()
                assert "Hello, world" in text

            loop.run_until_complete(test_get_route())

Example 2

Project: aiohttp Source File: test_test_utils.py
def test_server_with_create_test_teardown():
    with loop_context() as loop:
        app = _create_example_app(loop)
        with _TestClient(app) as client:

            @asyncio.coroutine
            def test_get_route():
                resp = yield from client.request("GET", "/")
                assert resp.status == 200
                text = yield from resp.text()
                assert "Hello, world" in text

            loop.run_until_complete(test_get_route())

Example 3

Project: aiohttp Source File: test_test_utils.py
Function: loop
@pytest.yield_fixture
def loop():
    with loop_context() as loop:
        yield loop

Example 4

Project: aiohttp Source File: test_web_sendfile_functional.py
Function: loop
@pytest.yield_fixture(params=LOOP_FACTORIES)
def loop(request):
    with loop_context(request.param) as loop:
        yield loop