Registry / testing / aiohttp-mock

aiohttp-mock

JSON →
library0.0.1pypypiunverified

A mocking library for aiohttp client requests to simplify testing. Current version 0.0.1, released infrequently. Designed for Python 3.6+.

pip install aiohttp-mock
INSTALL
IMPORT
SIG · AIOHTTP-MOCK
A
aiohttp-mock
testingpythonv0.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AiohttpMock
from aiohttp_mock import AiohttpMock
from aiohttp_mock import AiohttpMock

Demonstrates basic mocking of a GET request with aiohttp-mock.

import asyncio from aiohttp_mock import AiohttpMock async def test_example(): async with AiohttpMock() as mock: mock.get('http://example.com', status=200, body='OK') async with aiohttp.ClientSession() as session: async with session.get('http://example.com') as resp: assert resp.status == 200 assert await resp.text() == 'OK' asyncio.run(test_example())
Debug
Known issues
gotchaAiohttpMock must be used as an async context manager to ensure proper teardown.
fix
Use `async with AiohttpMock() as mock:` syntax.
affects: all
gotchaLibrary is in early development (v0.0.1); API may change without notice.
fix
Pin to exact version and review changelog before upgrading.
affects: <=0.0.1
deprecatedThe `body` parameter is expected to be a string; passing bytes may fail.
fix
Ensure body is a string or use `data` with bytes if supported.
affects: 0.0.1
Upgrade
Version history
0.0.1latest on PyPI · released Nov 23, 2022
Audit
Dependencies
aiohttprequiredaiohttp is required for mocking client sessions
Agent activity
49 hits · last 30 days
node
42
OpenAI (training)
1
Resources

No resource links recorded.

aiohttp-mock — pip install aiohttp-mock · libregistry