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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 2Python 3

File details

Details for the file webtest-aiohttp-1.1.0.tar.gz.

File metadata

File hashes

Hashes for webtest-aiohttp-1.1.0.tar.gz
Algorithm Hash digest
SHA256 f6da1a6c40def842c8e37f480c2f31e1f40deb10f1c1fd7f63cb3b21bc15f37c
MD5 288cd735c2ded66a5538f14da61adc30
BLAKE2b-256 f0e55285f906f072828a99fd9dbf7a376dd4aaaa3da74963745f3233de6cda35

See more details on using hashes here.

File details

Details for the file webtest_aiohttp-1.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for webtest_aiohttp-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a99721b902511d16bcb6cd4f23c5981e3897c19e9b3d4a119b7ad08f4949f908
MD5 f562e1e3dd34539ddc7cff8f642ded71
BLAKE2b-256 b6b09ede58f937212f688de8e1b7997125bb17d58ba3e42f97c8fa16167e7dc1

See more details on using hashes here.

Supported by

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