# pytest-aiohttp

> Pytest plugin for aiohttp support

- **URL**: https://www.freshcrate.ai/projects/pytest-aiohttp
- **Author**: aiohttp team
- **Category**: Frameworks
- **Latest version**: `1.1.0` (2026-04-21)
- **License**: Apache 2.0
- **Source**: https://github.com/aio-libs/pytest-aiohttp/blob/master/CHANGES.rst
- **Homepage**: https://github.com/aio-libs/pytest-aiohttp
- **Language**: Python
- **GitHub**: 143 stars, 23 forks
- **Registry**: pypi (`pytest-aiohttp`)
- **Tags**: `pypi`

## Description

pytest-aiohttp
==============

pytest plugin for aiohttp support

The library provides useful fixtures for creation test aiohttp server and client.


Installation
------------

.. code-block:: console

    $ pip install pytest-aiohttp

Add ``asyncio_mode = auto`` line to `pytest configuration
<https://docs.pytest.org/en/latest/customize.html>`_ (see `pytest-asyncio modes
<https://github.com/pytest-dev/pytest-asyncio#modes>`_ for details).  The plugin works
with ``strict`` mode also.



Usage
-----

Write tests in `pytest-asyncio <https://github.com/pytest-dev/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:

.. code-block:: python

    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.

## Recent releases

| Version | Date | Urgency | Changes |
| --- | --- | --- | --- |
| `1.1.0` | 2026-04-21 | Low | Imported from PyPI (1.1.0) |
| `v1.1.0` | 2025-01-23 | Low | pytest-aiohttp ==============  pytest plugin for aiohttp support  The library provides useful fixtures for creation test aiohttp server and client.   Installation ------------  .. code-block:: console      $ pip install pytest-aiohttp  Add ``asyncio_mode = auto`` line to `pytest configuration <https://docs.pytest.org/en/latest/customize.html>`_ (see `pytest-asyncio modes <https://github.com/pytest-dev/pytest-asyncio#modes>`_ for details).  The plugin works with ``strict`` mode also.    Usage --- |
| `v1.1.0` | 2025-01-23 | Low | pytest-aiohttp ==============  pytest plugin for aiohttp support  The library provides useful fixtures for creation test aiohttp server and client.   Installation ------------  .. code-block:: console      $ pip install pytest-aiohttp  Add ``asyncio_mode = auto`` line to `pytest configuration <https://docs.pytest.org/en/latest/customize.html>`_ (see `pytest-asyncio modes <https://github.com/pytest-dev/pytest-asyncio#modes>`_ for details).  The plugin works with ``strict`` mode also.    Usage --- |
| `v1.1.0` | 2025-01-23 | Low | pytest-aiohttp ==============  pytest plugin for aiohttp support  The library provides useful fixtures for creation test aiohttp server and client.   Installation ------------  .. code-block:: console      $ pip install pytest-aiohttp  Add ``asyncio_mode = auto`` line to `pytest configuration <https://docs.pytest.org/en/latest/customize.html>`_ (see `pytest-asyncio modes <https://github.com/pytest-dev/pytest-asyncio#modes>`_ for details).  The plugin works with ``strict`` mode also.    Usage --- |
| `v1.1.0` | 2025-01-23 | Low | pytest-aiohttp ==============  pytest plugin for aiohttp support  The library provides useful fixtures for creation test aiohttp server and client.   Installation ------------  .. code-block:: console      $ pip install pytest-aiohttp  Add ``asyncio_mode = auto`` line to `pytest configuration <https://docs.pytest.org/en/latest/customize.html>`_ (see `pytest-asyncio modes <https://github.com/pytest-dev/pytest-asyncio#modes>`_ for details).  The plugin works with ``strict`` mode also.    Usage --- |
| `v1.1.0` | 2025-01-23 | Low | pytest-aiohttp ==============  pytest plugin for aiohttp support  The library provides useful fixtures for creation test aiohttp server and client.   Installation ------------  .. code-block:: console      $ pip install pytest-aiohttp  Add ``asyncio_mode = auto`` line to `pytest configuration <https://docs.pytest.org/en/latest/customize.html>`_ (see `pytest-asyncio modes <https://github.com/pytest-dev/pytest-asyncio#modes>`_ for details).  The plugin works with ``strict`` mode also.    Usage --- |
| `v1.1.0` | 2025-01-23 | Low | pytest-aiohttp ==============  pytest plugin for aiohttp support  The library provides useful fixtures for creation test aiohttp server and client.   Installation ------------  .. code-block:: console      $ pip install pytest-aiohttp  Add ``asyncio_mode = auto`` line to `pytest configuration <https://docs.pytest.org/en/latest/customize.html>`_ (see `pytest-asyncio modes <https://github.com/pytest-dev/pytest-asyncio#modes>`_ for details).  The plugin works with ``strict`` mode also.    Usage --- |
| `v1.1.0` | 2025-01-23 | Low | pytest-aiohttp ==============  pytest plugin for aiohttp support  The library provides useful fixtures for creation test aiohttp server and client.   Installation ------------  .. code-block:: console      $ pip install pytest-aiohttp  Add ``asyncio_mode = auto`` line to `pytest configuration <https://docs.pytest.org/en/latest/customize.html>`_ (see `pytest-asyncio modes <https://github.com/pytest-dev/pytest-asyncio#modes>`_ for details).  The plugin works with ``strict`` mode also.    Usage --- |
| `v1.1.0` | 2025-01-23 | Low | pytest-aiohttp ==============  pytest plugin for aiohttp support  The library provides useful fixtures for creation test aiohttp server and client.   Installation ------------  .. code-block:: console      $ pip install pytest-aiohttp  Add ``asyncio_mode = auto`` line to `pytest configuration <https://docs.pytest.org/en/latest/customize.html>`_ (see `pytest-asyncio modes <https://github.com/pytest-dev/pytest-asyncio#modes>`_ for details).  The plugin works with ``strict`` mode also.    Usage --- |
| `v1.1.0` | 2025-01-23 | Low | pytest-aiohttp ==============  pytest plugin for aiohttp support  The library provides useful fixtures for creation test aiohttp server and client.   Installation ------------  .. code-block:: console      $ pip install pytest-aiohttp  Add ``asyncio_mode = auto`` line to `pytest configuration <https://docs.pytest.org/en/latest/customize.html>`_ (see `pytest-asyncio modes <https://github.com/pytest-dev/pytest-asyncio#modes>`_ for details).  The plugin works with ``strict`` mode also.    Usage --- |

## Citation

- HTML: https://www.freshcrate.ai/projects/pytest-aiohttp
- Markdown: https://www.freshcrate.ai/projects/pytest-aiohttp.md
- Dependencies JSON: https://www.freshcrate.ai/api/projects/pytest-aiohttp/deps

_Generated by freshcrate.ai. Indexes pypi releases for AI-agent ecosystem packages._
