webtest-aiohttp provides integration of WebTest with aiohttp.web applications
Project description
webtest-aiohttp provides integration of WebTest with aiohttp.web applications
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
Project Links
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.0.0.tar.gz
(4.0 kB
view details)
Built Distribution
File details
Details for the file webtest-aiohttp-1.0.0.tar.gz
.
File metadata
- Download URL: webtest-aiohttp-1.0.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c8125e29776125d156e72be3659d0a35511e7785609fde9476acb61ebf7902a |
|
MD5 | 714346924ccc4648b0da3d7f72b37e3e |
|
BLAKE2b-256 | 74b75a7b03964db9c315427541069aa5a89d7bea0ef33cb8bc0b5a97781770a7 |
File details
Details for the file webtest_aiohttp-1.0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: webtest_aiohttp-1.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90fb082d2578bed37ce9eb8489dc2eb8e9bc30cafe294e857ef23334f2a9334e |
|
MD5 | 4457637e35173dda6a121aad9fbd1858 |
|
BLAKE2b-256 | 1368f6a49410228cd81de128b38361548f1e38f34d324c7ffec4eb1414b6b848 |