Skip to content

Commit

Permalink
Drop 3.5 (#4046)
Browse files Browse the repository at this point in the history
(cherry picked from commit cfb40b7)
  • Loading branch information
asvetlov authored and webknjaz committed Sep 10, 2022
1 parent 9e4c83d commit 72d3550
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 43 deletions.
1 change: 1 addition & 0 deletions CHANGES/4046.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Drop Python 3.5 support, aiohttp works on 3.6+ now.
4 changes: 0 additions & 4 deletions docs/web_advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -627,10 +627,6 @@ one ``yield``.
*aiohttp* guarantees that *cleanup code* is called if and only if
*startup code* was successfully finished.

Asynchronous generators are supported by Python 3.6+, on Python 3.5
please use `async_generator <https://pypi.org/project/async_generator/>`_
library.

.. versionadded:: 3.1

.. _aiohttp-web-nested-applications:
Expand Down
4 changes: 1 addition & 3 deletions tests/test_client_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from unittest import mock

import pytest
from async_generator import async_generator, yield_
from multidict import MultiDict
from yarl import URL

Expand Down Expand Up @@ -2916,10 +2915,9 @@ async def handler(request):

client = await aiohttp_client(app)

@async_generator
async def gen():
for i in range(100):
await yield_(b"1234567890")
yield b"1234567890"

resp = await client.post("/", data=gen())
assert resp.status == 200
Expand Down
20 changes: 8 additions & 12 deletions tests/test_client_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from unittest import mock

import pytest
from async_generator import async_generator, yield_
from multidict import CIMultiDict, CIMultiDictProxy, istr
from yarl import URL

Expand Down Expand Up @@ -943,10 +942,9 @@ async def test_expect_100_continue_header(loop, conn) -> None:


async def test_data_stream(loop, buf, conn) -> None:
@async_generator
async def gen():
await yield_(b"binary data")
await yield_(b" result")
yield b"binary data"
yield b" result"

req = ClientRequest("POST", URL("http://python.org/"), data=gen(), loop=loop)
assert req.chunked
Expand Down Expand Up @@ -1008,9 +1006,8 @@ async def test_data_file(loop, buf, conn) -> None:
async def test_data_stream_exc(loop, conn) -> None:
fut = loop.create_future()

@async_generator
async def gen():
await yield_(b"binary data")
yield b"binary data"
await fut

req = ClientRequest("POST", URL("http://python.org/"), data=gen(), loop=loop)
Expand All @@ -1033,9 +1030,10 @@ async def throw_exc():
async def test_data_stream_exc_chain(loop, conn) -> None:
fut = loop.create_future()

@async_generator
async def gen():
await fut
return
yield

req = ClientRequest("POST", URL("http://python.org/"), data=gen(), loop=loop)

Expand All @@ -1059,10 +1057,9 @@ async def throw_exc():


async def test_data_stream_continue(loop, buf, conn) -> None:
@async_generator
async def gen():
await yield_(b"binary data")
await yield_(b" result")
yield b"binary data"
yield b" result"

req = ClientRequest(
"POST", URL("http://python.org/"), data=gen(), expect100=True, loop=loop
Expand Down Expand Up @@ -1104,10 +1101,9 @@ async def coro():


async def test_close(loop, buf, conn) -> None:
@async_generator
async def gen():
await asyncio.sleep(0.00001)
await yield_(b"result")
yield b"result"

req = ClientRequest("POST", URL("http://python.org/"), data=gen(), loop=loop)
resp = await req.send(conn)
Expand Down
9 changes: 4 additions & 5 deletions tests/test_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from unittest import mock

import pytest
from async_generator import async_generator

from aiohttp import payload, streams

Expand Down Expand Up @@ -99,18 +98,18 @@ def test_string_io_payload() -> None:


def test_async_iterable_payload_default_content_type() -> None:
@async_generator
async def gen():
pass
return
yield

p = payload.AsyncIterablePayload(gen())
assert p.content_type == "application/octet-stream"


def test_async_iterable_payload_explicit_content_type() -> None:
@async_generator
async def gen():
pass
return
yield

p = payload.AsyncIterablePayload(gen(), content_type="application/custom")
assert p.content_type == "application/custom"
Expand Down
21 changes: 7 additions & 14 deletions tests/test_web_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from unittest import mock

import pytest
from async_generator import async_generator, yield_

from aiohttp import log, web
from aiohttp.abc import AbstractAccessLogger, AbstractRouter
Expand Down Expand Up @@ -378,10 +377,9 @@ async def test_cleanup_ctx() -> None:
out = []

def f(num):
@async_generator
async def inner(app):
out.append("pre_" + str(num))
await yield_(None)
yield None
out.append("post_" + str(num))

return inner
Expand All @@ -402,12 +400,11 @@ async def test_cleanup_ctx_exception_on_startup() -> None:
exc = Exception("fail")

def f(num, fail=False):
@async_generator
async def inner(app):
out.append("pre_" + str(num))
if fail:
raise exc
await yield_(None)
yield None
out.append("post_" + str(num))

return inner
Expand All @@ -431,10 +428,9 @@ async def test_cleanup_ctx_exception_on_cleanup() -> None:
exc = Exception("fail")

def f(num, fail=False):
@async_generator
async def inner(app):
out.append("pre_" + str(num))
await yield_(None)
yield None
out.append("post_" + str(num))
if fail:
raise exc
Expand Down Expand Up @@ -484,10 +480,9 @@ async def test_cleanup_ctx_exception_on_cleanup_multiple() -> None:
out = []

def f(num, fail=False):
@async_generator
async def inner(app):
out.append("pre_" + str(num))
await yield_(None)
yield None
out.append("post_" + str(num))
if fail:
raise Exception("fail_" + str(num))
Expand All @@ -514,12 +509,11 @@ async def test_cleanup_ctx_multiple_yields() -> None:
out = []

def f(num):
@async_generator
async def inner(app):
out.append("pre_" + str(num))
await yield_(None)
yield None
out.append("post_" + str(num))
await yield_(None)
yield None

return inner

Expand Down Expand Up @@ -609,12 +603,11 @@ async def on_startup(app):
ctx_pre_called = False
ctx_post_called = False

@async_generator
async def cleanup_ctx(app):
nonlocal ctx_pre_called, ctx_post_called
ctx_pre_called = True
app[cleanup] = True
await yield_(None)
yield None
ctx_post_called = True

subapp.cleanup_ctx.append(cleanup_ctx)
Expand Down
7 changes: 2 additions & 5 deletions tests/test_web_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from unittest import mock

import pytest
from async_generator import async_generator, yield_
from multidict import CIMultiDictProxy, MultiDict
from yarl import URL

Expand Down Expand Up @@ -759,12 +758,11 @@ async def test_response_with_async_gen(aiohttp_client, fname) -> None:

data_size = len(data)

@async_generator
async def stream(f_name):
with f_name.open("rb") as f:
data = f.read(100)
while data:
await yield_(data)
yield data
data = f.read(100)

async def handler(request):
Expand Down Expand Up @@ -821,12 +819,11 @@ async def test_response_with_async_gen_no_params(aiohttp_client, fname) -> None:

data_size = len(data)

@async_generator
async def stream():
with fname.open("rb") as f:
data = f.read(100)
while data:
await yield_(data)
yield data
data = f.read(100)

async def handler(request):
Expand Down

0 comments on commit 72d3550

Please sign in to comment.