Skip to main content

Pytest plugin for aiohttp support

Project description

pytest plugin for aiohttp support

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

Installation

$ pip install pytest-aiohttp

Add asyncio_mode = auto line to pytest configuration (see pytest-asyncio modes for details). The plugin works with strict mode also.

Usage

Write tests in 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:

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-aiohttp-1.0.4.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

pytest_aiohttp-1.0.4-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file pytest-aiohttp-1.0.4.tar.gz.

File metadata

  • Download URL: pytest-aiohttp-1.0.4.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for pytest-aiohttp-1.0.4.tar.gz
Algorithm Hash digest
SHA256 39ff3a0d15484c01d1436cbedad575c6eafbf0f57cdf76fb94994c97b5b8c5a4
MD5 62f9a96948dbc417b93e16262a404f06
BLAKE2b-256 11fa64b1bbc2514c934fd8cd251cc91ba38faa533c3fbbab5b7cf17d54b05e22

See more details on using hashes here.

Provenance

File details

Details for the file pytest_aiohttp-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: pytest_aiohttp-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for pytest_aiohttp-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1d2dc3a304c2be1fd496c0c2fb6b31ab60cd9fc33984f761f951f8ea1eb4ca95
MD5 eed169a1957ee2367449f510d15bf461
BLAKE2b-256 02ee871f5d1833e7a3f2325796ab9509de52fd934ca71a37cffbea5c3b6d7ecf

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page