{"id":23276,"library":"aresponses","title":"aresponses","description":"Asyncio response mocking library for aiohttp-based code, similar to responses for requests. Version 3.0.0 supports asyncio and aiohttp. Released sporadically.","status":"active","version":"3.0.0","language":"python","source_language":"en","source_url":"https://github.com/aresponses/aresponses","tags":["testing","mocking","asyncio","aiohttp"],"install":[{"cmd":"pip install aresponses","lang":"bash","label":"PyPI"}],"dependencies":[],"imports":[{"note":"Class name with capital 'M' and capital 'S' ","wrong":"","symbol":"ResponsesMockServer","correct":"from aresponses import ResponsesMockServer"}],"quickstart":{"code":"import aiohttp\nimport asyncio\nfrom aresponses import ResponsesMockServer\n\nasync def test_fetch():\n    async with aiohttp.ClientSession() as session:\n        async with session.get('http://example.com/api') as resp:\n            data = await resp.json()\n            assert data == {'key': 'value'}\n\nasync def main():\n    async with ResponsesMockServer() as server:\n        server.add('http://example.com/api', 'GET', response={'key': 'value'})\n        await test_fetch()\n\nasyncio.run(main())","lang":"python","description":"Basic usage of ResponsesMockServer context manager with aiohttp."},"warnings":[{"fix":"Use 'async with ResponsesMockServer() as server:'","message":"ResponsesMockServer must be used as an async context manager, not a regular context manager. Forgetting 'async with' will cause a RuntimeError.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace 'aresponses.match(...)' with 'ResponsesMockServer().add(...)' and use async context manager.","message":"Version 3.0.0 changed the API from the old 'aresponses' function-based approach to the class-based 'ResponsesMockServer'. Old code using 'aresponses.match' or 'aresponses.add' directly no longer works.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Import 'ResponsesMockServer' and use its async context manager.","message":"The 'aresponses' module-level functions like 'aresponses.add' and 'aresponses.match' are removed in 3.0.0. Direct attribute access to 'RequestsMock' is no longer supported.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Use 'from aresponses import ...'","message":"responses (the synchronous library) is sometimes confused with aresponses. Ensure you import from 'aresponses' not 'responses'.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use 'ResponsesMockServer' class with 'add' method instead: 'from aresponses import ResponsesMockServer' and use 'server.add(...)'.","cause":"Trying to use old API pattern (aresponses.match) in version 3.0.0.","error":"AttributeError: module 'aresponses' has no attribute 'match'"},{"fix":"Change 'with' to 'async with' inside an async function.","cause":"Using 'with ResponsesMockServer()' instead of 'async with' inside an async function.","error":"RuntimeError: cannot use async context manager outside of an async function"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}