{"id":13482189,"url":"https://github.com/pnuckowski/aioresponses","last_synced_at":"2026-02-19T02:02:38.598Z","repository":{"id":37686618,"uuid":"71044055","full_name":"pnuckowski/aioresponses","owner":"pnuckowski","description":"Aioresponses is a helper for mock/fake web requests in python aiohttp package.","archived":false,"fork":false,"pushed_at":"2025-06-10T09:03:51.000Z","size":308,"stargazers_count":550,"open_issues_count":64,"forks_count":90,"subscribers_count":5,"default_branch":"master","last_synced_at":"2026-02-13T23:50:30.588Z","etag":null,"topics":["aiohttp","asyncio","mocking","test"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pnuckowski.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.rst","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-16T10:42:14.000Z","updated_at":"2026-02-13T11:57:52.000Z","dependencies_parsed_at":"2024-03-06T10:44:06.163Z","dependency_job_id":"badc197c-4212-4f6e-ade4-f3146619fa60","html_url":"https://github.com/pnuckowski/aioresponses","commit_stats":{"total_commits":187,"total_committers":47,"mean_commits":3.978723404255319,"dds":0.572192513368984,"last_synced_commit":"f330e715fa706e589f1e972d61b920b6617156e1"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/pnuckowski/aioresponses","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnuckowski%2Faioresponses","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnuckowski%2Faioresponses/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnuckowski%2Faioresponses/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnuckowski%2Faioresponses/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pnuckowski","download_url":"https://codeload.github.com/pnuckowski/aioresponses/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnuckowski%2Faioresponses/sbom","scorecard":{"id":739220,"data":{"date":"2025-08-11","repo":{"name":"github.com/pnuckowski/aioresponses","commit":"ad791963f7a9f03338ce312f992d95f9ebbc7552"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Code-Review","score":6,"reason":"Found 9/14 approved changesets -- score normalized to 6","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Warn: no topLevel permission defined: .github/workflows/flake8.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:88: update your workflow using https://app.stepsecurity.io/secureworkflow/pnuckowski/aioresponses/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:90: update your workflow using https://app.stepsecurity.io/secureworkflow/pnuckowski/aioresponses/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:100: update your workflow using https://app.stepsecurity.io/secureworkflow/pnuckowski/aioresponses/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/flake8.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/pnuckowski/aioresponses/flake8.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/flake8.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/pnuckowski/aioresponses/flake8.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/flake8.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/pnuckowski/aioresponses/flake8.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/ci.yml:95","Warn: pipCommand not pinned by hash: .github/workflows/ci.yml:96","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   0 out of   2 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"19 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2013-9 / GHSA-4gv5-qhvr-36vv","Warn: Project is vulnerable to: PYSEC-2021-437 / GHSA-5xp3-jfq3-5q8x","Warn: Project is vulnerable to: PYSEC-2019-160 / GHSA-c5h8-cq4v-cvfm","Warn: Project is vulnerable to: PYSEC-2013-8 / GHSA-g3p5-fjj9-h8gj","Warn: Project is vulnerable to: PYSEC-2020-173 / GHSA-gpvv-69j7-gwj8","Warn: Project is vulnerable to: PYSEC-2023-228 / GHSA-mq26-g339-26xf","Warn: Project is vulnerable to: PYSEC-2022-43017 / GHSA-qwmp-2cf2-g9g6","Warn: Project is vulnerable to: PYSEC-2023-120 / GHSA-45c4-8wx5-qw6w","Warn: Project is vulnerable to: GHSA-5m98-qgg9-wh84","Warn: Project is vulnerable to: GHSA-7gpw-8wmc-pm8g","Warn: Project is vulnerable to: GHSA-8495-4g3g-x7pr","Warn: Project is vulnerable to: PYSEC-2024-26 / GHSA-8qpw-xqxj-h4r2","Warn: Project is vulnerable to: GHSA-9548-qrrj-x5pj","Warn: Project is vulnerable to: PYSEC-2023-246 / GHSA-gfw2-4jvh-wgfg","Warn: Project is vulnerable to: GHSA-pjjw-qhg8-p2p9","Warn: Project is vulnerable to: PYSEC-2023-250 / GHSA-q3qx-c6g2-7pw2","Warn: Project is vulnerable to: PYSEC-2023-251 / GHSA-qvrw-v9rv-5rjx","Warn: Project is vulnerable to: PYSEC-2021-76 / GHSA-v6wp-4m6f-gcjg","Warn: Project is vulnerable to: PYSEC-2023-247 / GHSA-xx9p-xxvh-7g8j"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 26 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-22T16:53:32.480Z","repository_id":37686618,"created_at":"2025-08-22T16:53:32.480Z","updated_at":"2025-08-22T16:53:32.480Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29600848,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T00:59:38.239Z","status":"online","status_checked_at":"2026-02-19T02:00:07.702Z","response_time":117,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aiohttp","asyncio","mocking","test"],"created_at":"2024-07-31T17:00:59.790Z","updated_at":"2026-02-19T02:02:38.574Z","avatar_url":"https://github.com/pnuckowski.png","language":"Python","funding_links":[],"categories":["Python","Topics Index","Web Testing","测试","Mock and Stub","Testing"],"sub_categories":["Unit Testing"],"readme":"===============================\naioresponses\n===============================\n\n.. image:: https://travis-ci.org/pnuckowski/aioresponses.svg?branch=master\n        :target: https://travis-ci.org/pnuckowski/aioresponses\n\n.. image:: https://coveralls.io/repos/github/pnuckowski/aioresponses/badge.svg?branch=master\n        :target: https://coveralls.io/github/pnuckowski/aioresponses?branch=master\n\n.. image:: https://landscape.io/github/pnuckowski/aioresponses/master/landscape.svg?style=flat\n        :target: https://landscape.io/github/pnuckowski/aioresponses/master\n        :alt: Code Health\n\n.. image:: https://pyup.io/repos/github/pnuckowski/aioresponses/shield.svg\n        :target: https://pyup.io/repos/github/pnuckowski/aioresponses/\n        :alt: Updates\n\n.. image:: https://img.shields.io/pypi/v/aioresponses.svg\n        :target: https://pypi.python.org/pypi/aioresponses\n\n.. image:: https://readthedocs.org/projects/aioresponses/badge/?version=latest\n        :target: https://aioresponses.readthedocs.io/en/latest/?badge=latest\n        :alt: Documentation Status\n\n\nAioresponses is a helper to mock/fake web requests in python aiohttp package.\n\nFor *requests* module there are a lot of packages that help us with testing (eg. *httpretty*, *responses*, *requests-mock*).\n\nWhen it comes to testing asynchronous HTTP requests it is a bit harder (at least at the beginning).\nThe purpose of this package is to provide an easy way to test asynchronous HTTP requests.\n\nInstalling\n----------\n\n.. code:: bash\n\n    $ pip install aioresponses\n\nSupported versions\n------------------\n- Python 3.7+\n- aiohttp\u003e=3.3.0,\u003c4.0.0\n\nUsage\n--------\n\nTo mock out HTTP request use *aioresponses* as a method decorator or as a context manager.\n\nResponse *status* code, *body*, *payload* (for json response) and *headers* can be mocked.\n\nSupported HTTP methods: **GET**, **POST**, **PUT**, **PATCH**, **DELETE** and **OPTIONS**.\n\n.. code:: python\n\n    import aiohttp\n    import asyncio\n    from aioresponses import aioresponses\n\n    @aioresponses()\n    def test_request(mocked):\n        loop = asyncio.get_event_loop()\n        mocked.get('http://example.com', status=200, body='test')\n        session = aiohttp.ClientSession()\n        resp = loop.run_until_complete(session.get('http://example.com'))\n\n        assert resp.status == 200\n        mocked.assert_called_once_with('http://example.com')\n\n\nfor convenience use *payload* argument to mock out json response. Example below.\n\n**as a context manager**\n\n.. code:: python\n\n    import asyncio\n    import aiohttp\n    from aioresponses import aioresponses\n\n    def test_ctx():\n        loop = asyncio.get_event_loop()\n        session = aiohttp.ClientSession()\n        with aioresponses() as m:\n            m.get('http://test.example.com', payload=dict(foo='bar'))\n\n            resp = loop.run_until_complete(session.get('http://test.example.com'))\n            data = loop.run_until_complete(resp.json())\n\n            assert dict(foo='bar') == data\n            m.assert_called_once_with('http://test.example.com')\n\n**aioresponses allows to mock out any HTTP headers**\n\n.. code:: python\n\n    import asyncio\n    import aiohttp\n    from aioresponses import aioresponses\n\n    @aioresponses()\n    def test_http_headers(m):\n        loop = asyncio.get_event_loop()\n        session = aiohttp.ClientSession()\n        m.post(\n            'http://example.com',\n            payload=dict(),\n            headers=dict(connection='keep-alive'),\n        )\n\n        resp = loop.run_until_complete(session.post('http://example.com'))\n\n        # note that we pass 'connection' but get 'Connection' (capitalized)\n        # under the neath `multidict` is used to work with HTTP headers\n        assert resp.headers['Connection'] == 'keep-alive'\n        m.assert_called_once_with('http://example.com', method='POST')\n\n**allows to register different responses for the same url**\n\n.. code:: python\n\n    import asyncio\n    import aiohttp\n    from aioresponses import aioresponses\n\n    @aioresponses()\n    def test_multiple_responses(m):\n        loop = asyncio.get_event_loop()\n        session = aiohttp.ClientSession()\n        m.get('http://example.com', status=500)\n        m.get('http://example.com', status=200)\n\n        resp1 = loop.run_until_complete(session.get('http://example.com'))\n        resp2 = loop.run_until_complete(session.get('http://example.com'))\n\n        assert resp1.status == 500\n        assert resp2.status == 200\n\n\n**Repeat response for the same url**  \n\nE.g. for cases where you want to test retrying mechanisms.\n\n- By default, ``repeat=False`` means the response is not repeated (``repeat=1`` does the same).\n- Use ``repeat=n`` to repeat a response n times.\n- Use ``repeat=True`` to repeat a response indefinitely.\n\n.. code:: python\n\n    import asyncio\n    import aiohttp\n    from aioresponses import aioresponses\n\n    @aioresponses()\n    def test_multiple_responses(m):\n        loop = asyncio.get_event_loop()\n        session = aiohttp.ClientSession()\n        m.get('http://example.com', status=500, repeat=2)\n        m.get('http://example.com', status=200)  # will take effect after two preceding calls\n\n        resp1 = loop.run_until_complete(session.get('http://example.com'))\n        resp2 = loop.run_until_complete(session.get('http://example.com'))\n        resp3 = loop.run_until_complete(session.get('http://example.com'))\n\n        assert resp1.status == 500\n        assert resp2.status == 500\n        assert resp3.status == 200\n\n\n**match URLs with regular expressions**\n\n.. code:: python\n\n    import asyncio\n    import aiohttp\n    import re\n    from aioresponses import aioresponses\n\n    @aioresponses()\n    def test_regexp_example(m):\n        loop = asyncio.get_event_loop()\n        session = aiohttp.ClientSession()\n        pattern = re.compile(r'^http://example\\.com/api\\?foo=.*$')\n        m.get(pattern, status=200)\n\n        resp = loop.run_until_complete(session.get('http://example.com/api?foo=bar'))\n\n        assert resp.status == 200\n\n**allows to make redirects responses**\n\n.. code:: python\n\n    import asyncio\n    import aiohttp\n    from aioresponses import aioresponses\n\n    @aioresponses()\n    def test_redirect_example(m):\n        loop = asyncio.get_event_loop()\n        session = aiohttp.ClientSession()\n\n        # absolute urls are supported\n        m.get(\n            'http://example.com/',\n            headers={'Location': 'http://another.com/'},\n            status=307\n        )\n\n        resp = loop.run_until_complete(\n            session.get('http://example.com/', allow_redirects=True)\n        )\n        assert resp.url == 'http://another.com/'\n\n        # and also relative\n        m.get(\n            'http://example.com/',\n            headers={'Location': '/test'},\n            status=307\n        )\n        resp = loop.run_until_complete(\n            session.get('http://example.com/', allow_redirects=True)\n        )\n        assert resp.url == 'http://example.com/test'\n\n**allows to passthrough to a specified list of servers**\n\n.. code:: python\n\n    import asyncio\n    import aiohttp\n    from aioresponses import aioresponses\n\n    @aioresponses(passthrough=['http://backend'])\n    def test_passthrough(m, test_client):\n        session = aiohttp.ClientSession()\n        # this will actually perform a request\n        resp = loop.run_until_complete(session.get('http://backend/api'))\n\n**also you can passthrough all requests except specified by mocking object**\n\n.. code:: python\n\n    import asyncio\n    import aiohttp\n    from aioresponses import aioresponses\n\n    @aioresponses(passthrough_unmatched=True)\n    def test_passthrough_unmatched(m, test_client):\n        url = 'https://httpbin.org/get'\n        m.get(url, status=200)\n        session = aiohttp.ClientSession()\n        # this will actually perform a request\n        resp = loop.run_until_complete(session.get('http://backend/api'))\n        # this will not perform a request and resp2.status will return 200\n        resp2 = loop.run_until_complete(session.get(url))\n\n**aioresponses allows to throw an exception**\n\n.. code:: python\n\n    import asyncio\n    from aiohttp import ClientSession\n    from aiohttp.http_exceptions import HttpProcessingError\n    from aioresponses import aioresponses\n\n    @aioresponses()\n    def test_how_to_throw_an_exception(m, test_client):\n        loop = asyncio.get_event_loop()\n        session = ClientSession()\n        m.get('http://example.com/api', exception=HttpProcessingError('test'))\n\n        # calling\n        # loop.run_until_complete(session.get('http://example.com/api'))\n        # will throw an exception.\n\n\n**aioresponses allows to use callbacks to provide dynamic responses**\n\n.. code:: python\n\n    import asyncio\n    import aiohttp\n    from aioresponses import CallbackResult, aioresponses\n\n    def callback(url, **kwargs):\n        return CallbackResult(status=418)\n\n    @aioresponses()\n    def test_callback(m, test_client):\n        loop = asyncio.get_event_loop()\n        session = ClientSession()\n        m.get('http://example.com', callback=callback)\n\n        resp = loop.run_until_complete(session.get('http://example.com'))\n\n        assert resp.status == 418\n\n\n**aioresponses can be used in a pytest fixture**\n\n.. code:: python\n\n    import pytest\n    from aioresponses import aioresponses\n\n    @pytest.fixture\n    def mock_aioresponse():\n        with aioresponses() as m:\n            yield m\n\n\nFeatures\n--------\n* Easy to mock out HTTP requests made by *aiohttp.ClientSession*\n\n\nLicense\n-------\n* Free software: MIT license\n\nCredits\n-------\n\nThis package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpnuckowski%2Faioresponses","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpnuckowski%2Faioresponses","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpnuckowski%2Faioresponses/lists"}