pytest-aiohttp


Namepytest-aiohttp JSON
Version 1.0.4 PyPI version JSON
download
home_pagehttps://github.com/aio-libs/pytest-aiohttp
SummaryPytest plugin for aiohttp support
upload_time2022-02-12 20:26:01
maintaineraiohttp team <team@aiohttp.org>
docs_urlNone
author
requires_python>=3.7
licenseApache 2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            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(await 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.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/aio-libs/pytest-aiohttp",
    "name": "pytest-aiohttp",
    "maintainer": "aiohttp team <team@aiohttp.org>",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "team@aiohttp.org",
    "keywords": "",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/11/fa/64b1bbc2514c934fd8cd251cc91ba38faa533c3fbbab5b7cf17d54b05e22/pytest-aiohttp-1.0.4.tar.gz",
    "platform": "",
    "description": "pytest-aiohttp\n==============\n\npytest plugin for aiohttp support\n\nThe library provides useful fixtures for creation test aiohttp server and client.\n\n\nInstallation\n------------\n\n.. code-block:: console\n\n    $ pip install pytest-aiohttp\n\nAdd ``asyncio_mode = auto`` line to `pytest configuration\n<https://docs.pytest.org/en/latest/customize.html>`_ (see `pytest-asyncio modes\n<https://github.com/pytest-dev/pytest-asyncio#modes>`_ for details).  The plugin works\nwith ``strict`` mode also.\n\n\n\nUsage\n-----\n\nWrite tests in `pytest-asyncio <https://github.com/pytest-dev/pytest-asyncio>`_ style\nusing provided fixtures for aiohttp test server and client creation. The plugin provides\nresources cleanup out-of-the-box.\n\nThe simple usage example:\n\n.. code-block:: python\n\n    from aiohttp import web\n\n\n    async def hello(request):\n        return web.Response(body=b\"Hello, world\")\n\n\n    def create_app():\n        app = web.Application()\n        app.router.add_route(\"GET\", \"/\", hello)\n        return app\n\n\n    async def test_hello(aiohttp_client):\n        client = await aiohttp_client(await create_app())\n        resp = await client.get(\"/\")\n        assert resp.status == 200\n        text = await resp.text()\n        assert \"Hello, world\" in text\n\n\nSee `aiohttp documentation <https://docs.aiohttp.org/en/stable/testing.html#pytest>` for\nmore details about fixtures usage.\n\n\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "Pytest plugin for aiohttp support",
    "version": "1.0.4",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "eed169a1957ee2367449f510d15bf461",
                "sha256": "1d2dc3a304c2be1fd496c0c2fb6b31ab60cd9fc33984f761f951f8ea1eb4ca95"
            },
            "downloads": -1,
            "filename": "pytest_aiohttp-1.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "eed169a1957ee2367449f510d15bf461",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 8566,
            "upload_time": "2022-02-12T20:25:59",
            "upload_time_iso_8601": "2022-02-12T20:25:59.358333Z",
            "url": "https://files.pythonhosted.org/packages/02/ee/871f5d1833e7a3f2325796ab9509de52fd934ca71a37cffbea5c3b6d7ecf/pytest_aiohttp-1.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "62f9a96948dbc417b93e16262a404f06",
                "sha256": "39ff3a0d15484c01d1436cbedad575c6eafbf0f57cdf76fb94994c97b5b8c5a4"
            },
            "downloads": -1,
            "filename": "pytest-aiohttp-1.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "62f9a96948dbc417b93e16262a404f06",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 11868,
            "upload_time": "2022-02-12T20:26:01",
            "upload_time_iso_8601": "2022-02-12T20:26:01.003501Z",
            "url": "https://files.pythonhosted.org/packages/11/fa/64b1bbc2514c934fd8cd251cc91ba38faa533c3fbbab5b7cf17d54b05e22/pytest-aiohttp-1.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-02-12 20:26:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "aio-libs",
    "github_project": "pytest-aiohttp",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pytest-aiohttp"
}
        
Elapsed time: 0.04327s