forked from pool/python-aiohttp
- Add patch to address name collision issue with pytest fixtures + rename-request-fixture.patch OBS-URL: https://build.opensuse.org/request/show/650538 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-aiohttp?expand=0&rev=29
166 lines
5.9 KiB
Diff
166 lines
5.9 KiB
Diff
diff -Nru aiohttp-3.4.4.orig/aiohttp/web_response.py aiohttp-3.4.4/aiohttp/web_response.py
|
|
--- aiohttp-3.4.4.orig/aiohttp/web_response.py 2018-09-05 09:40:54.000000000 +0200
|
|
+++ aiohttp-3.4.4/aiohttp/web_response.py 2018-11-20 13:49:49.197173589 +0100
|
|
@@ -279,27 +279,27 @@
|
|
# remove the header
|
|
self._headers.popall(hdrs.CONTENT_LENGTH, None)
|
|
|
|
- def _start_compression(self, request):
|
|
+ def _start_compression(self, mock_request):
|
|
if self._compression_force:
|
|
self._do_start_compression(self._compression_force)
|
|
else:
|
|
- accept_encoding = request.headers.get(
|
|
+ accept_encoding = mock_request.headers.get(
|
|
hdrs.ACCEPT_ENCODING, '').lower()
|
|
for coding in ContentCoding:
|
|
if coding.value in accept_encoding:
|
|
self._do_start_compression(coding)
|
|
return
|
|
|
|
- async def prepare(self, request):
|
|
+ async def prepare(self, mock_request):
|
|
if self._eof_sent:
|
|
return
|
|
if self._payload_writer is not None:
|
|
return self._payload_writer
|
|
|
|
- await request._prepare_hook(self)
|
|
- return await self._start(request)
|
|
+ await mock_request._prepare_hook(self)
|
|
+ return await self._start(mock_request)
|
|
|
|
- async def _start(self, request,
|
|
+ async def _start(self, mock_request,
|
|
HttpVersion10=HttpVersion10,
|
|
HttpVersion11=HttpVersion11,
|
|
CONNECTION=hdrs.CONNECTION,
|
|
@@ -310,15 +310,15 @@
|
|
SET_COOKIE=hdrs.SET_COOKIE,
|
|
SERVER_SOFTWARE=SERVER_SOFTWARE,
|
|
TRANSFER_ENCODING=hdrs.TRANSFER_ENCODING):
|
|
- self._req = request
|
|
+ self._req = mock_request
|
|
|
|
keep_alive = self._keep_alive
|
|
if keep_alive is None:
|
|
- keep_alive = request.keep_alive
|
|
+ keep_alive = mock_request.keep_alive
|
|
self._keep_alive = keep_alive
|
|
|
|
- version = request.version
|
|
- writer = self._payload_writer = request._payload_writer
|
|
+ version = mock_request.version
|
|
+ writer = self._payload_writer = mock_request._payload_writer
|
|
|
|
headers = self._headers
|
|
for cookie in self._cookies.values():
|
|
@@ -326,13 +326,13 @@
|
|
headers.add(SET_COOKIE, value)
|
|
|
|
if self._compression:
|
|
- self._start_compression(request)
|
|
+ self._start_compression(mock_request)
|
|
|
|
if self._chunked:
|
|
if version != HttpVersion11:
|
|
raise RuntimeError(
|
|
"Using chunked encoding is forbidden "
|
|
- "for HTTP/{0.major}.{0.minor}".format(request.version))
|
|
+ "for HTTP/{0.major}.{0.minor}".format(mock_request.version))
|
|
writer.enable_chunking()
|
|
headers[TRANSFER_ENCODING] = 'chunked'
|
|
if CONTENT_LENGTH in headers:
|
|
@@ -597,7 +597,7 @@
|
|
else:
|
|
await super().write_eof()
|
|
|
|
- async def _start(self, request):
|
|
+ async def _start(self, mock_request):
|
|
if not self._chunked and hdrs.CONTENT_LENGTH not in self._headers:
|
|
if not self._body_payload:
|
|
if self._body is not None:
|
|
@@ -605,7 +605,7 @@
|
|
else:
|
|
self._headers[hdrs.CONTENT_LENGTH] = '0'
|
|
|
|
- return await super()._start(request)
|
|
+ return await super()._start(mock_request)
|
|
|
|
def _do_start_compression(self, coding):
|
|
if self._body_payload or self._chunked:
|
|
diff -Nru aiohttp-3.4.4.orig/tests/test_client_connection.py aiohttp-3.4.4/tests/test_client_connection.py
|
|
--- aiohttp-3.4.4.orig/tests/test_client_connection.py 2018-09-05 09:40:55.000000000 +0200
|
|
+++ aiohttp-3.4.4/tests/test_client_connection.py 2018-11-20 13:38:21.602987474 +0100
|
|
@@ -12,7 +12,7 @@
|
|
|
|
|
|
@pytest.fixture
|
|
-def request():
|
|
+def mock_request():
|
|
return mock.Mock()
|
|
|
|
|
|
diff -Nru aiohttp-3.4.4.orig/tests/test_web_exceptions.py aiohttp-3.4.4/tests/test_web_exceptions.py
|
|
--- aiohttp-3.4.4.orig/tests/test_web_exceptions.py 2018-09-05 09:40:55.000000000 +0200
|
|
+++ aiohttp-3.4.4/tests/test_web_exceptions.py 2018-11-20 14:04:51.565410583 +0100
|
|
@@ -15,7 +15,7 @@
|
|
|
|
|
|
@pytest.fixture
|
|
-def request(buf):
|
|
+def mock_request(buf):
|
|
method = 'GET'
|
|
path = '/'
|
|
writer = mock.Mock()
|
|
@@ -54,9 +54,9 @@
|
|
assert name in web.__all__
|
|
|
|
|
|
-async def test_HTTPOk(buf, request):
|
|
+async def test_HTTPOk(buf, mock_request):
|
|
resp = web.HTTPOk()
|
|
- await resp.prepare(request)
|
|
+ await resp.prepare(mock_request)
|
|
await resp.write_eof()
|
|
txt = buf.decode('utf8')
|
|
assert re.match(('HTTP/1.1 200 OK\r\n'
|
|
@@ -87,11 +87,11 @@
|
|
assert 1 == codes.most_common(1)[0][1]
|
|
|
|
|
|
-async def test_HTTPFound(buf, request):
|
|
+async def test_HTTPFound(buf, mock_request):
|
|
resp = web.HTTPFound(location='/redirect')
|
|
assert '/redirect' == resp.location
|
|
assert '/redirect' == resp.headers['location']
|
|
- await resp.prepare(request)
|
|
+ await resp.prepare(mock_request)
|
|
await resp.write_eof()
|
|
txt = buf.decode('utf8')
|
|
assert re.match('HTTP/1.1 302 Found\r\n'
|
|
@@ -111,12 +111,12 @@
|
|
web.HTTPFound(location=None)
|
|
|
|
|
|
-async def test_HTTPMethodNotAllowed(buf, request):
|
|
+async def test_HTTPMethodNotAllowed(buf, mock_request):
|
|
resp = web.HTTPMethodNotAllowed('get', ['POST', 'PUT'])
|
|
assert 'GET' == resp.method
|
|
assert ['POST', 'PUT'] == resp.allowed_methods
|
|
assert 'POST,PUT' == resp.headers['allow']
|
|
- await resp.prepare(request)
|
|
+ await resp.prepare(mock_request)
|
|
await resp.write_eof()
|
|
txt = buf.decode('utf8')
|
|
assert re.match('HTTP/1.1 405 Method Not Allowed\r\n'
|
|
@@ -168,7 +168,7 @@
|
|
resp.body is None
|
|
|
|
|
|
-def test_link_header_451(buf, request):
|
|
+def test_link_header_451(buf, mock_request):
|
|
resp = web.HTTPUnavailableForLegalReasons(link='http://warning.or.kr/')
|
|
|
|
assert 'http://warning.or.kr/' == resp.link
|