Metadata-Version: 2.4
Name: pytest-aiohttp
Version: 1.1.1
Summary: Pytest plugin for aiohttp support
Home-page: https://github.com/aio-libs/pytest-aiohttp
Maintainer: aiohttp team <team@aiohttp.org>
Maintainer-email: team@aiohttp.org
License: Apache 2.0
Project-URL: GitHub, https://github.com/aio-libs/pytest-aiohttp
Project-URL: Changelog, https://github.com/aio-libs/pytest-aiohttp/blob/master/CHANGES.rst
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Testing
Classifier: Framework :: AsyncIO
Classifier: Framework :: Pytest
Classifier: Framework :: aiohttp
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: pytest>=6.1.0
Requires-Dist: aiohttp>=3.11.0
Requires-Dist: pytest-asyncio>=0.17.2
Provides-Extra: testing
Requires-Dist: coverage==7.14.1; extra == "testing"
Requires-Dist: mypy==2.1.0; extra == "testing"
Dynamic: license-file

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.
