Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests #2000

Merged
merged 6 commits into from
Jun 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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