Skip to main content

pytest-aiohttp-client

Awesome pytest fixture for awesome aiohttp!

test Coverage Status Code style: black Python versions PyPi

Installation

Install it via pip tool:

pip install pytest-aiohttp-client

or Poetry:

poetry add yandex-geocoder

Usage example

Plugin provides api fixture, but you should define aiohttp_app fixture first:

import pytest

from my_awesome_app import make_app


@pytest.fixture
def aiohttp_app() -> Application:
  return make_app()

Default decoding

Fixture will decode and return payload by default as json or bytes (depends on Content-Type header):

async def test_returns_json(api):
    got = await api.get("/json-url/")

    assert got == {"key": "value"}


async def test_returns_bytes(api):
    got = await api.get("/url/")

    assert got == b"Some text"

Status code assertions

You can assert on status code:

async def test_returns_ok(api):
    await api.get("/url/", expected_status=200)

Response result

Type as_response=True if you need ClientResponse object:

from aiohttp.client import ClientResponse

async def test_returns_response(api):
    got = await api.get("/url/", as_response=True)

    assert isinstance(got, ClientResponse)

Development and contribution

First of all you should install Poetry.

  • install project dependencies
make install
  • run linters
make lint
  • run tests
make test
  • feel free to contribute!

Release files for pytest-aiohttp-client 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-aiohttp-client 0.1.0
File Size Uploaded
pytest_aiohttp_client-0.1.0.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-aiohttp-client 0.1.0
File Interpreter ABI Platform
pytest_aiohttp_client-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.6 kB

Release files / pytest_aiohttp_client-0.1.0.tar.gz

Download URL pytest_aiohttp_client-0.1.0.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ae2dad8e3db052b3fd0296ce8d542d7f04a911f23f2d82f2777021815e88a708
BLAKE2b-256 checksum
How to use checksums
16b72fd2ac57a0ceb1ea6d75cd5f82122469225f81e33d57745c039a3389ce4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.1 CPython/3.11.1 Linux/5.15.0-1024-azure

Release files / pytest_aiohttp_client-0.1.0-py3-none-any.whl

Download URL pytest_aiohttp_client-0.1.0-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b20ed9234d3d19493c5a02ff9ccb97a30766f01c11ddd3502b73b665334844f1
BLAKE2b-256 checksum
How to use checksums
54ea8b8bd7383a0a4f11b6356e6a0b49f230e901805f5bf44747d32ce7f4fc2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.1 CPython/3.11.1 Linux/5.15.0-1024-azure

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page