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.
Release files for pytest-aiohttp 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest_aiohttp-1.1.1.tar.gz | 13.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_aiohttp-1.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.7 kB
Release files / pytest_aiohttp-1.1.1.tar.gz
| Download URL | pytest_aiohttp-1.1.1.tar.gz |
|---|---|
| Size | 13.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3aa9c9fe26e543eaccc7eb0add381c685ba3ed3e2fed0af74540f63bcd31458d
|
|
BLAKE2b-256 checksum How to use checksums |
514dc6621fc79022f6c84a806e23d9b7eca24fae4f3ee779219bbe524339d666
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Release files / pytest_aiohttp-1.1.1-py3-none-any.whl
| Download URL | pytest_aiohttp-1.1.1-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f293441ad4f8446a1e12257130c26c7de03a615c2a5572a8cb046e5b3b4e5211
|
|
BLAKE2b-256 checksum How to use checksums |
fab05056ed4c3f68a4db2b4a39fb0ec61b1e4cf1d89ee14effe5261cc587264c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|