Use OrderedDict from .compat module

This commit is contained in:
Piotr Jurkiewicz
2016-04-15 04:43:53 +02:00
parent 4f5741e1ff
commit c8a0fc6aa2
2 changed files with 5 additions and 3 deletions
+3 -1
View File
@@ -10,6 +10,8 @@ Data structures that power Requests.
import collections
from .compat import OrderedDict
class CaseInsensitiveDict(collections.MutableMapping):
"""
@@ -40,7 +42,7 @@ class CaseInsensitiveDict(collections.MutableMapping):
"""
def __init__(self, data=None, **kwargs):
self._store = collections.OrderedDict()
self._store = OrderedDict()
if data is None:
data = {}
self.update(data, **kwargs)
+2 -2
View File
@@ -318,11 +318,11 @@ class TestRequests:
def test_headers_preserve_order(self, httpbin):
"""Preserve order when headers provided as OrderedDict."""
ses = requests.Session()
ses.headers = collections.OrderedDict()
ses.headers = OrderedDict()
ses.headers['Accept-Encoding'] = 'identity'
ses.headers['First'] = '1'
ses.headers['Second'] = '2'
headers = collections.OrderedDict([('Third', '3'), ('Fourth', '4')])
headers = OrderedDict([('Third', '3'), ('Fourth', '4')])
headers['Fifth'] = '5'
headers['Second'] = '222'
req = requests.Request('GET', httpbin('get'), headers = headers)