Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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

Project Description

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

Supports aiohttp>=2.3.8.

from aiohttp import web
from webtest_aiohttp import TestApp

app = web.Application()

async def hello(request):
    return web.json_response({'message': 'Hello world'})

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

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

Installation

pip install webtest-aiohttp

Note: If you are using aiohttp<2.0.0, you will need to install webtest-aiohttp 1.x.

pip install 'webtest-aiohttp<2.0.0'

Usage with pytest

If you are using pytest and pytest-aiohttp, you can make your tests more concise with a fixture.

from aiohttp import web
from webtest_aiohttp import TestApp as WebTestApp

app = web.Application()

async def hello(request):
    return web.json_response({'message': 'Hello world'})

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

@pytest.fixture()
def testapp(loop):
    return WebTestApp(app, loop=loop)

def test_get(testapp):
    assert testapp.get('/').json == {'message': 'Hello world'}

License

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

Release History

This version
History Node

2.0.0

History Node

1.1.1

History Node

1.1.0

History Node

1.0.0

Download Files

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

File Name & Hash SHA256 Hash Help Version File Type Upload Date
webtest_aiohttp-2.0.0-py2.py3-none-any.whl
(4.8 kB) Copy SHA256 Hash SHA256
py2.py3 Wheel Feb 8, 2018
webtest-aiohttp-2.0.0.tar.gz
(8.4 kB) Copy SHA256 Hash SHA256
Source Feb 8, 2018

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting