RequestsMock doesn't catch requests that are sent inside the default asyncio executor. As a result, real HTTP requests are sent.
Additional context
Python 3.9 - 3.11
Version of responses
0.24.1
Steps to Reproduce
import asyncio
import responses
import requests
def send_request():
# Here a real HTTP request will be sent
response = requests.get('https://example.com/')
print(response.content)
def main():
with responses.RequestsMock(assert_all_requests_are_fired=False) as rsps:
rsps.get('https://example.com/', body='test')
loop = asyncio.get_event_loop()
loop.run_in_executor(None, send_request)
# but send_request() works correct and DOES NOT send a real HTTP request
main()
Expected Result
test should be printed.
Actual Result
A real HTTP request is sent to https://example.com/, and a page body b'<!doctype html>\n<html>\n<head>\n <title>Example Domain</title>.... is printed.
Describe the bug
RequestsMock
doesn't catch requests that are sent inside the default asyncio executor. As a result, real HTTP requests are sent.Additional context
Python 3.9 - 3.11
Version of
responses
0.24.1
Steps to Reproduce
Expected Result
test
should be printed.Actual Result
A real HTTP request is sent to https://example.com/, and a page body
b'<!doctype html>\n<html>\n<head>\n <title>Example Domain</title>....
is printed.