Skip to content
Myr

Add pickle test with hooks

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Keyan Pishdadian · committed by Nate Prewitt · parent 117813e · Browse files · 1 file+21 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+21 added−0 removed

  • tests:+21 added−0 removed

1 file+21 added−0 removed

modified:tests/test_requests.py+21 added
1088 unmodified lines
1089 r = s.send(r)10901091 assert r.status_code == 20010921093 def test_prepared_request_with_hook_is_pickleable(self):1094 def print_url(r, *args, **kwargs):1095 print(r.url)10961097 r = requests.Request('POST', httpbin('post'), hooks=dict(response=print_url))1098 p = r.prepare()10991100 # Verify we can pickle the request.1101 assert pickle.dumps(p)1102 r = pickle.dumps(p)11031104 # Verify we can use the pickled request.1105 assert pickle.loads(r)1106 r = pickle.loads(r)11071108 # Verify we can use the unpickled request.1109 s = requests.Session()1110 r = s.send(r)11111112 assert r.status_code == 20011131114 def test_cannot_send_unprepared_requests(self, httpbin):1115 r = requests.Request(url=httpbin())1116 with pytest.raises(ValueError):1117 requests.Session().send(r)
765 unmodified lines