Skip to main content

webtest-aiohttp provides integration of WebTest with aiohttp.web applications

Project description

Latest version Travis-CI

webtest-aiohttp provides integration of WebTest with aiohttp.web applications.

Supports aiohttp>=0.21.0.

import asyncio

from aiohttp import web
from webtest_aiohttp import TestApp

loop = asyncio.get_event_loop()
asyncio.set_event_loop(loop)

app = web.Application(loop=loop)

@asyncio.coroutine
def hello(request):
    return web.Response(body=json.dumps(
        {'message': 'Hello world'}
    ).encode('utf-8'), content_type='application/json')

app.router.add_route('GET', '/', handler)


def test_hello():
    client = TestApp(app)
    res = client.get('/')
    assert res.status_code == 200
    assert res.json == {'message': 'Hello world'}

Installation

pip install webtest-aiohttp

Credits

This code was adapted from Kirill Klenov’s muffin library.

License

MIT licensed. See the bundled LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

webtest-aiohttp-1.1.0.tar.gz (4.1 kB view hashes)

Uploaded Source

Built Distribution

webtest_aiohttp-1.1.0-py2.py3-none-any.whl (6.1 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page