Pytest plugin for aiohttp support
Project Links
Meta
Maintainer: aiohttp team <team@aiohttp.org>
Requires Python: >=3.9
Classifiers
Development Status
- 4 - Beta
Intended Audience
- Developers
License
- OSI Approved :: Apache Software License
Programming Language
- Python :: 3.9
- Python :: 3.10
- Python :: 3.11
- Python :: 3.12
- Python :: 3.13
Topic
- Software Development :: Testing
Framework
- AsyncIO
- Pytest
- aiohttp
Typing
- Typed
pytest plugin for aiohttp support
The library provides useful fixtures for creation test aiohttp server and client.
Installation
$ pip install pytest-aiohttp
Add asyncio_mode = auto line to pytest configuration (see pytest-asyncio modes for details). The plugin works with strict mode also.
Usage
Write tests in pytest-asyncio style using provided fixtures for aiohttp test server and client creation. The plugin provides resources cleanup out-of-the-box.
The simple usage example:
from aiohttp import web
async def hello(request):
return web.Response(body=b"Hello, world")
def create_app():
app = web.Application()
app.router.add_route("GET", "/", hello)
return app
async def test_hello(aiohttp_client):
client = await aiohttp_client(create_app())
resp = await client.get("/")
assert resp.status == 200
text = await resp.text()
assert "Hello, world" in text
See aiohttp documentation <https://docs.aiohttp.org/en/stable/testing.html#pytest> for more details about fixtures usage.
Jan 23, 2025
1.1.0
Sep 06, 2023
1.0.5
Feb 12, 2022
1.0.4
Jan 21, 2022
1.0.3
Jan 20, 2022
1.0.2
Jan 20, 2022
1.0.1
Jan 20, 2022
1.0.0
Dec 05, 2017
0.3.0
Nov 30, 2017
0.2.0
Sep 08, 2016
0.1.3
Aug 07, 2016
0.1.2
Jul 22, 2016
0.1.1
Jul 22, 2016
0.1.0
Jul 22, 2016
0.0.1a0