Skip to content

Commit

Permalink
add a readme description about passthrough_unmatched flag
Browse files Browse the repository at this point in the history
  • Loading branch information
outp1 committed Mar 3, 2023
1 parent 379cf88 commit 538d910
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand Down

0 comments on commit 538d910

Please sign in to comment.