Skip to content
Myr

Use OrderedDict from .compat module

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 4f5741e · Browse files · 2 files+5 added−3 removed
This commit

State

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

Diff stats

2 files+5 added−3 removed

  • tests:+2 added−2 removed
  • other:+3 added−1 removed

2 files+5 added−3 removed

modified:requests/structures.py+3 added-1 removed
8 unmodified lines
9"""1011import collections1213from .compat import OrderedDict141516class CaseInsensitiveDict(collections.MutableMapping):17 """18 A case-insensitive ``dict``-like object.19
21 unmodified lines
41 behavior is undefined.4243 """44 def __init__(self, data=None, **kwargs):43 self._store = collections.OrderedDict()45 self._store = OrderedDict()46 if data is None:47 data = {}48 self.update(data, **kwargs)49
57 unmodified lines
modified:tests/test_requests.py+2 added-2 removed
316 unmodified lines
317318 def test_headers_preserve_order(self, httpbin):319 """Preserve order when headers provided as OrderedDict."""320 ses = requests.Session()321 ses.headers = collections.OrderedDict()321 ses.headers = 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')])325 headers = 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)
1268 unmodified lines