From 538d910ec9517623bb0416e5cb4c3189d283a893 Mon Sep 17 00:00:00 2001 From: outp1 Date: Fri, 3 Mar 2023 17:53:10 +0300 Subject: [PATCH] add a readme description about passthrough_unmatched flag --- README.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.rst b/README.rst index 77b6687..dc4542d 100644 --- a/README.rst +++ b/README.rst @@ -232,6 +232,22 @@ E.g. for cases you want to test retrying mechanisms # this will actually perform a request resp = loop.run_until_complete(session.get('http://backend/api')) +**also you can passthrough all requests except specified by mocking object** + +.. code:: python + import asyncio + import aiohttp + from aioresponses import aioresponses + + @aioresponses(passthrough_unmatched=True) + def test_passthrough_unmatched(m, test_client): + url = 'https://httpbin.org/get' + m.get(url, status=200) + session = aiohttp.ClientSession() + # this will actually perform a request + resp = loop.run_until_complete(session.get('http://backend/api')) + # this will not perform a request and resp2.status will return 200 + resp2 = loop.run_until_complete(session.get(url)) **aioresponses allows to throw an exception**