Testing Hook Dispatch Mechanism in Requests Library
This test suite validates the hook dispatch functionality and default hook behavior in the Requests library. It ensures proper execution of response hooks and verifies the default hook configuration.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
psf/requests
tests/test_hooks.py
import pytest
from requests import hooks
def hook(value):
return value[1:]
@pytest.mark.parametrize(
"hooks_list, result",
(
(hook, "ata"),
([hook, lambda x: None, hook], "ta"),
),
)
def test_hooks(hooks_list, result):
assert hooks.dispatch_hook("response", {"response": hooks_list}, "Data") == result
def test_default_hooks():
assert hooks.default_hooks() == {"response": []}