Skip to main content

No project description provided

Project description

Proof of concept for an aioresponses-like library that uses real aiohttp server related to this discussion: https://github.com/orgs/aio-libs/discussions/45

This is a proof of concept of how a linrary could expose aioresponses-like API while using real aiohttp server under the hood. It works only with GET requests, only compare the url, param and method, and only implements assert_called_with.

The breaking changes will be:

  • The context manager will be async, as it will need to start the server
  • the assert_called_* methods will not work with arbitrary kwargs, instead they will only work with specific args that the request was made with (e.g. url, method, headers, params, etc.)
  • the fragments (after #) are not being passed on the request, so will not be compared
  • on a connector exception, aiohttp could retry, so the number of request will not be the same
  • pass timeout don't work
  • you cant raise exceptions exception clienterror
  • the decorathor need to decorate an async function
  • as this mock DNS will not work to mock request to external IPs

Added a perf test to compare the performance of the POC with the original aioresponses implementation.

Results:

aioresponses (main) : 0.7223 seconds for 1000 iter (0.72 ms/iter) aioresponses_2 (POC) : 0.8272 seconds for 1000 iter (0.83 ms/iter)

Probablly this overheard is tolerable, and could be optimized. However, once we start adding more features, the performance will degrade.

Changing:

@pytest.fixture def mock_aioresponse(): with aioresponses() as m:

to:

@pytest_asyncio.fixture async def mock_aioresponse(): async with aioresponses() as m: yield m

is passing the tests on:

https://github.com/cortega26/PDF-Text-Analyzer https://github.com/mxr/reconciler-for-ynab https://github.com/pratik-choudhari/Financial-news-scraper /with some unrelated changes because is broken https://github.com/dorianrod/GitReviewLens

https://github.com/natekspencer/pylitterbot required some changes:

  • there were raising a custom exception on request on test_litter_robot_5_dispatch_command_failure, and that is not supported.
    • However, they were try to mimick a 500 with certain json that was supported
  • There were some calls to localhost, that should be to https://localhost. This was also a fixable error on the tests

Broken on main https://github.com/symphony-youri/symphony-api-client-python.git

too complex to work: https://github.com/mguidon/osparc-simcore

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

aiointercept-0.1.0.tar.gz (103.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiointercept-0.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file aiointercept-0.1.0.tar.gz.

File metadata

  • Download URL: aiointercept-0.1.0.tar.gz
  • Upload date:
  • Size: 103.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for aiointercept-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e65edd126a187080830ef85336dfd7d81649855f458faf162dc8a560d3ac245e
MD5 33ceb29296ec1f10daa32ded42c28124
BLAKE2b-256 fbd3ade6f86abb771d11c8ff5e1be111a00ca858642af4f198394db812f7d279

See more details on using hashes here.

File details

Details for the file aiointercept-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: aiointercept-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for aiointercept-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 659715441a43fcbd5b2b78cbb9607c27541209c3302453106bd8023dd86d3ea8
MD5 1aff5938ced71d72904fe114816e3441
BLAKE2b-256 e1c4bdecd3f6d20f61a94a582280c328355f6fc558ef6ea156854a675d644524

See more details on using hashes here.

Supported by

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