test_header_with_subclass_types() — requests Function Reference
Architecture documentation for the test_header_with_subclass_types() function in test_requests.py from the requests codebase.
Entity Profile
Dependency Diagram
graph TD 34ffbdf6_d929_5249_7668_75cd80723005["test_header_with_subclass_types()"] 22b80b19_26d4_cd0e_c476_3edf87b3df14["TestRequests"] 34ffbdf6_d929_5249_7668_75cd80723005 -->|defined in| 22b80b19_26d4_cd0e_c476_3edf87b3df14 style 34ffbdf6_d929_5249_7668_75cd80723005 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_requests.py lines 1822–1845
def test_header_with_subclass_types(self, httpbin):
"""If the subclasses does not behave *exactly* like
the base bytes/str classes, this is not supported.
This test is for backwards compatibility.
"""
class MyString(str):
pass
class MyBytes(bytes):
pass
r_str = requests.get(httpbin("get"), headers={MyString("x-custom"): "myheader"})
assert r_str.request.headers["x-custom"] == "myheader"
r_bytes = requests.get(
httpbin("get"), headers={MyBytes(b"x-custom"): b"myheader"}
)
assert r_bytes.request.headers["x-custom"] == b"myheader"
r_mixed = requests.get(
httpbin("get"), headers={MyString("x-custom"): MyBytes(b"myheader")}
)
assert r_mixed.request.headers["x-custom"] == b"myheader"
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_header_with_subclass_types() do?
test_header_with_subclass_types() is a function in the requests codebase, defined in tests/test_requests.py.
Where is test_header_with_subclass_types() defined?
test_header_with_subclass_types() is defined in tests/test_requests.py at line 1822.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free