https://github.com/sloria/webtest-aiohttp
Integration of WebTest with aiohttp.web applications
https://github.com/sloria/webtest-aiohttp
aiohttp asyncio python-3 testing webtest wsgi
Last synced: 2 months ago
JSON representation
Integration of WebTest with aiohttp.web applications
- Host: GitHub
- URL: https://github.com/sloria/webtest-aiohttp
- Owner: sloria
- License: mit
- Created: 2015-10-20T01:52:19.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2023-01-22T00:47:14.000Z (over 2 years ago)
- Last Synced: 2025-07-10T12:57:30.569Z (3 months ago)
- Topics: aiohttp, asyncio, python-3, testing, webtest, wsgi
- Language: Python
- Size: 29.3 KB
- Stars: 8
- Watchers: 2
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- License: LICENSE
Awesome Lists containing this project
README
***************
webtest-aiohttp
***************.. image:: https://badge.fury.io/py/webtest-aiohttp.svg
:target: http://badge.fury.io/py/webtest-aiohttp
:alt: Latest version.. image:: https://travis-ci.org/sloria/webtest-aiohttp.svg
:target: https://travis-ci.org/sloria/webtest-aiohttp
:alt: Travis-CIwebtest-aiohttp provides integration of WebTest with aiohttp.web applications.
Supports aiohttp>=2.3.8.
.. code-block:: python
from aiohttp import web
from webtest_aiohttp import TestAppapp = 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... code-block:: python
from aiohttp import web
from webtest_aiohttp import TestApp as WebTestAppapp = 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'}Project Links
=============- PyPI: https://pypi.python.org/pypi/webtest-aiohttp
- Issues: https://github.com/sloria/webtest-aiohttp/issuesLicense
=======MIT licensed. See the bundled `LICENSE `_ file for more details.