Pytest plugin for aiohttp support
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_aiohttp-1.1.0.tar.gz.
File metadata
- Download URL: pytest_aiohttp-1.1.0.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
147de8cb164f3fc9d7196967f109ab3c0b93ea3463ab50631e56438eab7b5adc
|
|
| MD5 |
890d8b15de35e7febed2fae98525480a
|
|
| BLAKE2b-256 |
724bd326890c153f2c4ce1bf45d07683c08c10a1766058a22934620bc6ac6592
|
File details
Details for the file pytest_aiohttp-1.1.0-py3-none-any.whl.
File metadata
- Download URL: pytest_aiohttp-1.1.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f39a11693a0dce08dd6c542d241e199dd8047a6e6596b2bcfa60d373f143456d
|
|
| MD5 |
8555dd02d61c7fb56ee8a0e05361ec52
|
|
| BLAKE2b-256 |
ba0fe6af71c02e0f1098eaf7d2dbf3ffdf0a69fc1e0ef174f96af05cef161f1b
|