Skip to content
Myr

Add tests around hook behaviour

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

authored by Ian Cordasco · committed by Ian Cordasco · parent 5bf396d · Browse files · 1 file+19 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+19 added−0 removed

  • other:+19 added−0 removed

1 file+19 added−0 removed

modified:test_requests.py+19 added
447 unmodified lines
448 assert kwargs != {}449450 requests.Request('GET', HTTPBIN, hooks={'response': hook})451452 def test_session_hooks_are_used_with_no_request_hooks(self):453 hook = lambda x, *args, **kwargs: x454 s = requests.Session()455 s.hooks['response'].append(hook)456 r = requests.Request('GET', HTTPBIN)457 prep = s.prepare_request(r)458 assert prep.hooks['response'] != []459 assert prep.hooks['response'] == [hook]460461 def test_session_hooks_are_overriden_by_request_hooks(self):462 hook1 = lambda x, *args, **kwargs: x463 hook2 = lambda x, *args, **kwargs: x464 assert hook1 is not hook2465 s = requests.Session()466 s.hooks['response'].append(hook2)467 r = requests.Request('GET', HTTPBIN, hooks={'response': [hook1]})468 prep = s.prepare_request(r)469 assert prep.hooks['response'] == [hook1]470471 def test_prepared_request_hook(self):472 def hook(resp, **kwargs):473 resp.hook_working = True474 return resp
416 unmodified lines