def build_request(addr="8.8.8.8", x_forwarded_for=None):
    "Creates a mock request with the given address and optional X-Forwarded-For header."
    meta = {"REMOTE_ADDR": addr}
    if x_forwarded_for:
        meta["HTTP_X_FORWARDED_FOR"] = x_forwarded_for
    return _client._build_request("GET", "/", {}, {"META": meta})
Creates a mock request with the given address and optional X-Forwarded-For header.
tests/test_throttling.py