MCPcopy Index your code
hub / github.com/python/cpython / test_request_headers_dict

Method test_request_headers_dict

Lib/test/test_urllib2.py:89–108  ·  view source on GitHub ↗

The Request.headers dictionary is not a documented interface. It should stay that way, because the complete set of headers are only accessible through the .get_header(), .has_header(), .header_items() interface. However, .headers pre-dates those methods, and so rea

(self)

Source from the content-addressed store, hash-verified

87class RequestHdrsTests(unittest.TestCase):
88
89 def test_request_headers_dict(self):
90 """
91 The Request.headers dictionary is not a documented interface. It
92 should stay that way, because the complete set of headers are only
93 accessible through the .get_header(), .has_header(), .header_items()
94 interface. However, .headers pre-dates those methods, and so real code
95 will be using the dictionary.
96
97 The introduction in 2.4 of those methods was a mistake for the same
98 reason: code that previously saw all (urllib2 user)-provided headers in
99 .headers now sees only a subset.
100
101 """
102 url = "http://example.com"
103 self.assertEqual(Request(url,
104 headers={"Spam-eggs": "blah"}
105 ).headers["Spam-eggs"], "blah")
106 self.assertEqual(Request(url,
107 headers={"spam-EggS": "blah"}
108 ).headers["Spam-eggs"], "blah")
109
110 def test_request_headers_methods(self):
111 """

Callers

nothing calls this directly

Calls 2

RequestClass · 0.90
assertEqualMethod · 0.45

Tested by

no test coverage detected