Which patch target makes this test intercept the HTTP call?
# app/services.py
from requests import get
def fetch_user(uid):
return get(f"https://api.example.com/users/{uid}").json()Options
patch("requests.get")patch("app.services.get")(Correct option)patch("requests.api.get")patch("get")
Answer
patch("app.services.get")
Why
from requests import get creates a NEW name get inside the module app.services, pointing to the function.
patch("requests.get") replaces the name inside the requests module, but app.services.get still points to the original function, so the real HTTP call happens.
Rule: patch the name where it is USED (looked up), not where it is defined.
Remember
Patch where the name is looked up.