requests-mock
requests-mock copied to clipboard
IP address lookup still happens with `requests_mock`?
How to prevent calling socket.gethostbyname
while using requests_mock
?
I still see DNS query sent out even though I mock the url.
Haven't looked into too deep, but I thought the mock adaptor should intercept before IP address lookup?
Here is the code to reproduce I'm using python3.11
import requests_mock
import requests
url = "https://random.dev"
with requests_mock.Mocker() as m:
m.get(url, text="test")
resp = requests.get(url)
assert resp.text == "test"
And then use tcpdump -i any udp port 53
(may need sudo
) to monitor DNS traffic.