Skip to content

Commit

Permalink
Adopt to multidict 3.0.0 (#2000)
Browse files Browse the repository at this point in the history
* Fix couple tests

* Another test

* Fix last tests

* Pin multidict requirement to 3.0.0

* Fix tests

* Make test stable
  • Loading branch information
asvetlov authored Jun 22, 2017
1 parent 6f2adac commit 075c34c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def update_headers(self, headers):

def update_auto_headers(self, skip_auto_headers):
self.skip_auto_headers = CIMultiDict(
(hdr, None) for hdr in skip_auto_headers)
(hdr, None) for hdr in sorted(skip_auto_headers))
used_headers = self.headers.copy()
used_headers.extend(self.skip_auto_headers)

Expand Down
2 changes: 1 addition & 1 deletion requirements-ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cython==0.25.2
chardet==3.0.4
isort==4.2.15
tox==2.7.0
multidict==2.1.6
multidict==3.0.0
async-timeout==1.2.1
sphinxcontrib-asyncio==0.2.0
sphinxcontrib-newsfeed==0.1.4
Expand Down
17 changes: 7 additions & 10 deletions tests/test_client_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_init_headers_simple_dict(create_session):
session = create_session(headers={"h1": "header1",
"h2": "header2"})
assert (sorted(session._default_headers.items()) ==
([("H1", "header1"), ("H2", "header2")]))
([("h1", "header1"), ("h2", "header2")]))


def test_init_headers_list_of_tuples(create_session):
Expand Down Expand Up @@ -126,26 +126,23 @@ def test_merge_headers(create_session):
headers = session._prepare_headers({"h1": "h1"})

assert isinstance(headers, CIMultiDict)
assert headers == CIMultiDict([("h2", "header2"),
("h1", "h1")])
assert headers == {"h1": "h1", "h2": "header2"}


def test_merge_headers_with_multi_dict(create_session):
session = create_session(headers={"h1": "header1",
"h2": "header2"})
headers = session._prepare_headers(MultiDict([("h1", "h1")]))
assert isinstance(headers, CIMultiDict)
assert headers == CIMultiDict([("h2", "header2"),
("h1", "h1")])
assert headers == {"h1": "h1", "h2": "header2"}


def test_merge_headers_with_list_of_tuples(create_session):
session = create_session(headers={"h1": "header1",
"h2": "header2"})
headers = session._prepare_headers([("h1", "h1")])
assert isinstance(headers, CIMultiDict)
assert headers == CIMultiDict([("h2", "header2"),
("h1", "h1")])
assert headers == {"h1": "h1", "h2": "header2"}


def test_merge_headers_with_list_of_tuples_duplicated_names(create_session):
Expand All @@ -156,9 +153,9 @@ def test_merge_headers_with_list_of_tuples_duplicated_names(create_session):
("h1", "v2")])

assert isinstance(headers, CIMultiDict)
assert headers == CIMultiDict([("H2", "header2"),
("H1", "v1"),
("H1", "v2")])
assert list(sorted(headers.items())) == [("h1", "v1"),
("h1", "v2"),
("h2", "header2")]


def test_http_GET(session, params):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_http_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def test_parse_headers(parser):
assert len(messages) == 1
msg = messages[0][0]

assert list(msg.headers.items()) == [('Test', 'line continue'),
('Test2', 'data')]
assert list(msg.headers.items()) == [('test', 'line continue'),
('test2', 'data')]
assert msg.raw_headers == ((b'test', b'line continue'),
(b'test2', b'data'))
assert not msg.should_close
Expand Down Expand Up @@ -134,7 +134,7 @@ def test_headers_multi_feed(parser):
assert len(messages) == 1

msg = messages[0][0]
assert list(msg.headers.items()) == [('Test', 'line continue')]
assert list(msg.headers.items()) == [('test', 'line continue')]
assert msg.raw_headers == ((b'test', b'line continue'),)
assert not msg.should_close
assert msg.compression is None
Expand Down
2 changes: 1 addition & 1 deletion tests/test_multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ def test_writer_write(buf, stream, writer):

b'--:\r\n'
b'Content-Type: multipart/mixed; boundary="::"\r\n'
b'X-Custom: test\r\nContent-Length: 93\r\n\r\n'
b'X-CUSTOM: test\r\nContent-Length: 93\r\n\r\n'
b'--::\r\n'
b'Content-Type: text/plain; charset=utf-8\r\n'
b'Content-Length: 14\r\n\r\n'
Expand Down
4 changes: 2 additions & 2 deletions tests/test_web_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_ctor(make_request):
assert req.protocol is protocol
assert req.transport is protocol.transport
assert req.headers == headers
assert req.raw_headers == ((b'Foo', b'bar'),)
assert req.raw_headers == ((b'FOO', b'bar'),)
assert req.task is req._task

with pytest.warns(DeprecationWarning):
Expand Down Expand Up @@ -361,7 +361,7 @@ def test_host_by_host_header(make_request):
def test_raw_headers(make_request):
req = make_request('GET', '/',
headers=CIMultiDict({'X-HEADER': 'aaa'}))
assert req.raw_headers == ((b'X-Header', b'aaa'),)
assert req.raw_headers == ((b'X-HEADER', b'aaa'),)


def test_rel_url(make_request):
Expand Down

0 comments on commit 075c34c

Please sign in to comment.