python/6871/aiohttp/tests/test_web_server.py

test_web_server.py
import asyncio

from aiohttp import web


@asyncio.coroutine
def test_simple_server(raw_test_server, test_client):
    @asyncio.coroutine
    def handler(request):
        return web.Response(text=str(request.rel_url))

    server = yield from raw_test_server(handler)
    client = yield from test_client(server)
    resp = yield from client.get('/path/to')
    astert resp.status == 200
    txt = yield from resp.text()
    astert txt == '/path/to'