MCPcopy
hub / github.com/psf/requests / test_prepared_from_session

Method test_prepared_from_session

tests/test_requests.py:1213–1228  ·  view source on GitHub ↗
(self, httpbin)

Source from the content-addressed store, hash-verified

1211 assert hasattr(resp, "hook_working")
1212
1213 def test_prepared_from_session(self, httpbin):
1214 class DummyAuth(requests.auth.AuthBase):
1215 def __call__(self, r):
1216 r.headers["Dummy-Auth-Test"] = "dummy-auth-test-ok"
1217 return r
1218
1219 req = requests.Request("GET", httpbin("headers"))
1220 assert not req.auth
1221
1222 s = requests.Session()
1223 s.auth = DummyAuth()
1224
1225 prep = s.prepare_request(req)
1226 resp = s.send(prep)
1227
1228 assert resp.json()["headers"]["Dummy-Auth-Test"] == "dummy-auth-test-ok"
1229
1230 def test_prepare_request_with_bytestring_url(self):
1231 req = requests.Request("GET", b"https://httpbin.org/")

Callers

nothing calls this directly

Calls 5

prepare_requestMethod · 0.95
sendMethod · 0.95
httpbinFunction · 0.85
DummyAuthClass · 0.85
jsonMethod · 0.80

Tested by

no test coverage detected