Skip to content
Myr

Add test of headers order preservation

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

authored by Piotr Jurkiewicz · committed by Piotr Jurkiewicz · parent 4c04469 · Browse files · 1 file+20 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+20 added−0 removed

  • tests:+20 added−0 removed

1 file+20 added−0 removed

modified:tests/test_requests.py+20 added
313 unmodified lines
314 req = requests.Request('GET', httpbin('get'))315 prep = ses.prepare_request(req)316 assert 'Accept-Encoding' not in prep.headers317318 def test_headers_preserve_order(self, httpbin):319 """Preserve order when headers provided as OrderedDict."""320 ses = requests.Session()321 ses.headers = collections.OrderedDict()322 ses.headers['Accept-Encoding'] = 'identity'323 ses.headers['First'] = '1'324 ses.headers['Second'] = '2'325 headers = collections.OrderedDict([('Third', '3'), ('Fourth', '4')])326 headers['Fifth'] = '5'327 headers['Second'] = '222'328 req = requests.Request('GET', httpbin('get'), headers = headers)329 prep = ses.prepare_request(req)330 items = prep.headers.items()331 assert items[0] == ('Accept-Encoding', 'identity')332 assert items[1] == ('First', '1')333 assert items[2] == ('Second', '222')334 assert items[3] == ('Third', '3')335 assert items[4] == ('Fourth', '4')336 assert items[5] == ('Fifth', '5')337338 @pytest.mark.parametrize('key', ('User-agent', 'user-agent'))339 def test_user_agent_transfers(self, httpbin, key):340341 heads = {key: 'Mozilla/5.0 (github.com/kennethreitz/requests)'}
1256 unmodified lines