Home / Function/ test_headers_preserve_order() — requests Function Reference

test_headers_preserve_order() — requests Function Reference

Architecture documentation for the test_headers_preserve_order() function in test_requests.py from the requests codebase.

Entity Profile

Dependency Diagram

graph TD
  d2ab763a_8128_10d6_5f5c_4e99821182ac["test_headers_preserve_order()"]
  22b80b19_26d4_cd0e_c476_3edf87b3df14["TestRequests"]
  d2ab763a_8128_10d6_5f5c_4e99821182ac -->|defined in| 22b80b19_26d4_cd0e_c476_3edf87b3df14
  style d2ab763a_8128_10d6_5f5c_4e99821182ac fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_requests.py lines 496–514

    def test_headers_preserve_order(self, httpbin):
        """Preserve order when headers provided as OrderedDict."""
        ses = requests.Session()
        ses.headers = collections.OrderedDict()
        ses.headers["Accept-Encoding"] = "identity"
        ses.headers["First"] = "1"
        ses.headers["Second"] = "2"
        headers = collections.OrderedDict([("Third", "3"), ("Fourth", "4")])
        headers["Fifth"] = "5"
        headers["Second"] = "222"
        req = requests.Request("GET", httpbin("get"), headers=headers)
        prep = ses.prepare_request(req)
        items = list(prep.headers.items())
        assert items[0] == ("Accept-Encoding", "identity")
        assert items[1] == ("First", "1")
        assert items[2] == ("Second", "222")
        assert items[3] == ("Third", "3")
        assert items[4] == ("Fourth", "4")
        assert items[5] == ("Fifth", "5")

Domain

Subdomains

Frequently Asked Questions

What does test_headers_preserve_order() do?
test_headers_preserve_order() is a function in the requests codebase, defined in tests/test_requests.py.
Where is test_headers_preserve_order() defined?
test_headers_preserve_order() is defined in tests/test_requests.py at line 496.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free