From 0b8cabb671790e0f848f1e045de1653e7947a69d Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 21 Jun 2017 18:41:04 +0300 Subject: [PATCH 1/6] Fix couple tests --- tests/test_client_session.py | 18 +++++++++--------- tests/test_http_parser.py | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/test_client_session.py b/tests/test_client_session.py index cd7b8adab6c..9b35b6519cd 100644 --- a/tests/test_client_session.py +++ b/tests/test_client_session.py @@ -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): @@ -126,8 +126,8 @@ 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 == CIMultiDict([("h1", "h1"), + ("h2", "header2")]) def test_merge_headers_with_multi_dict(create_session): @@ -135,8 +135,8 @@ def test_merge_headers_with_multi_dict(create_session): "h2": "header2"}) headers = session._prepare_headers(MultiDict([("h1", "h1")])) assert isinstance(headers, CIMultiDict) - assert headers == CIMultiDict([("h2", "header2"), - ("h1", "h1")]) + assert headers == CIMultiDict([("h1", "h1"), + ("h2", "header2")]) def test_merge_headers_with_list_of_tuples(create_session): @@ -144,8 +144,8 @@ def test_merge_headers_with_list_of_tuples(create_session): "h2": "header2"}) headers = session._prepare_headers([("h1", "h1")]) assert isinstance(headers, CIMultiDict) - assert headers == CIMultiDict([("h2", "header2"), - ("h1", "h1")]) + assert headers == CIMultiDict([("h1", "h1"), + ("h2", "header2")]) def test_merge_headers_with_list_of_tuples_duplicated_names(create_session): @@ -156,8 +156,8 @@ 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"), + assert headers == CIMultiDict([("H1", "v1"), + ("H2", "header2"), ("H1", "v2")]) diff --git a/tests/test_http_parser.py b/tests/test_http_parser.py index 4173765870c..3d677bde884 100644 --- a/tests/test_http_parser.py +++ b/tests/test_http_parser.py @@ -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 @@ -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 From faa71f783cca3d0171ce7a87a9974627330ec2df Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 21 Jun 2017 18:44:03 +0300 Subject: [PATCH 2/6] Another test --- tests/test_multipart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_multipart.py b/tests/test_multipart.py index e3dd38ab909..d879adbe139 100644 --- a/tests/test_multipart.py +++ b/tests/test_multipart.py @@ -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' From c91e3d7a50862c47b990a4a2dab334c14daeb499 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 21 Jun 2017 18:46:12 +0300 Subject: [PATCH 3/6] Fix last tests --- tests/test_web_request.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_web_request.py b/tests/test_web_request.py index 440cfd71e59..36c16823cd0 100644 --- a/tests/test_web_request.py +++ b/tests/test_web_request.py @@ -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): @@ -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): From a888eb0ab27b88813c992887e64f37da54aa51e3 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 21 Jun 2017 19:02:26 +0300 Subject: [PATCH 4/6] Pin multidict requirement to 3.0.0 --- requirements-ci.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-ci.txt b/requirements-ci.txt index e40e3143441..f7f27755934 100644 --- a/requirements-ci.txt +++ b/requirements-ci.txt @@ -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 From ac3774d6c6c55f9c8a3217767d0750b50f8968da Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Thu, 22 Jun 2017 19:23:43 +0300 Subject: [PATCH 5/6] Fix tests --- aiohttp/client_reqrep.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiohttp/client_reqrep.py b/aiohttp/client_reqrep.py index b1a9939aec7..ee810cf4564 100644 --- a/aiohttp/client_reqrep.py +++ b/aiohttp/client_reqrep.py @@ -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) From 0ab94f9d16530a24f72663b7a6b43db301377dc9 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Thu, 22 Jun 2017 19:38:58 +0300 Subject: [PATCH 6/6] Make test stable --- tests/test_client_session.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/test_client_session.py b/tests/test_client_session.py index 9b35b6519cd..fc01f5198e4 100644 --- a/tests/test_client_session.py +++ b/tests/test_client_session.py @@ -126,8 +126,7 @@ def test_merge_headers(create_session): headers = session._prepare_headers({"h1": "h1"}) assert isinstance(headers, CIMultiDict) - assert headers == CIMultiDict([("h1", "h1"), - ("h2", "header2")]) + assert headers == {"h1": "h1", "h2": "header2"} def test_merge_headers_with_multi_dict(create_session): @@ -135,8 +134,7 @@ def test_merge_headers_with_multi_dict(create_session): "h2": "header2"}) headers = session._prepare_headers(MultiDict([("h1", "h1")])) assert isinstance(headers, CIMultiDict) - assert headers == CIMultiDict([("h1", "h1"), - ("h2", "header2")]) + assert headers == {"h1": "h1", "h2": "header2"} def test_merge_headers_with_list_of_tuples(create_session): @@ -144,8 +142,7 @@ def test_merge_headers_with_list_of_tuples(create_session): "h2": "header2"}) headers = session._prepare_headers([("h1", "h1")]) assert isinstance(headers, CIMultiDict) - assert headers == CIMultiDict([("h1", "h1"), - ("h2", "header2")]) + assert headers == {"h1": "h1", "h2": "header2"} def test_merge_headers_with_list_of_tuples_duplicated_names(create_session): @@ -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([("H1", "v1"), - ("H2", "header2"), - ("H1", "v2")]) + assert list(sorted(headers.items())) == [("h1", "v1"), + ("h1", "v2"), + ("h2", "header2")] def test_http_GET(session, params):