Skip to content

Commit 0735b62

Browse files
Enable tests on 3.8+ (#616)
1 parent f975fbc commit 0735b62

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python-version: [3.6, 3.7]
11+
python-version: [3.6, 3.7, 3.8, 3.9]
1212

1313
steps:
1414
- name: Checkout

aiohttp_session/redis_storage.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ def __init__(
4444
)
4545
if aioredis is None:
4646
raise RuntimeError("Please install aioredis")
47-
if StrictVersion(aioredis.__version__).version < (1, 0):
48-
raise RuntimeError("aioredis<1.0 is not supported")
47+
# May have installed aioredis separately (without aiohttp-session[aioredis]).
48+
if StrictVersion(aioredis.__version__).version < (2, 0):
49+
raise RuntimeError("aioredis<2.0 is not supported")
4950
self._key_factory = key_factory
5051
if not isinstance(redis_pool, aioredis.Redis):
5152
raise TypeError(f"Expected aioredis.Redis got {type(redis_pool)}")

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def read(f):
2121

2222
install_requires = ["aiohttp>=3.8", 'typing_extensions>=3.7.4; python_version<"3.8"']
2323
extras_require = {
24-
"aioredis": ["aioredis>=1.0.0"],
24+
"aioredis": ["aioredis>=2.0.0"],
2525
"aiomcache": ["aiomcache>=0.5.2"],
2626
"pycrypto": ["cryptography"],
2727
"secure": ["cryptography"],

tests/conftest.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
from typing_extensions import TypedDict
1818

1919

20+
# TODO: Remove once fixed: https://github.com/aio-libs/aioredis-py/issues/1115
21+
aioredis.Redis.__del__ = lambda *args: None # type: ignore
22+
23+
2024
class _ContainerInfo(TypedDict):
2125
host: str
2226
port: int
@@ -61,7 +65,8 @@ def session_id() -> str:
6165
@pytest.fixture(scope="session")
6266
def docker() -> DockerClient: # type: ignore[misc] # No docker types.
6367
client = docker_from_env(version="auto")
64-
return client
68+
yield client
69+
client.close()
6570

6671

6772
@pytest.fixture(scope="session")
@@ -107,6 +112,10 @@ def redis_server( # type: ignore[misc] # No docker types.
107112
except ConnectionError:
108113
time.sleep(delay)
109114
delay *= 2
115+
finally:
116+
loop.run_until_complete(conn.close())
117+
# TODO: Remove once fixed: github.com/aio-libs/aioredis-py/issues/1103
118+
loop.run_until_complete(conn.connection_pool.disconnect())
110119
else:
111120
pytest.fail("Cannot start redis server")
112121

@@ -133,9 +142,8 @@ async def start(pool: aioredis.ConnectionPool) -> aioredis.Redis:
133142
pool = aioredis.ConnectionPool.from_url(redis_url)
134143
redis = loop.run_until_complete(start(pool))
135144
yield redis
136-
if redis is not None:
137-
redis.close() # type: ignore[no-untyped-call]
138-
loop.run_until_complete(pool.disconnect())
145+
loop.run_until_complete(redis.close()) # type: ignore[no-untyped-call]
146+
loop.run_until_complete(pool.disconnect())
139147

140148

141149
@pytest.fixture(scope="session")
@@ -181,6 +189,8 @@ def memcached_server( # type: ignore[misc] # No docker types.
181189
except ConnectionRefusedError:
182190
time.sleep(delay)
183191
delay *= 2
192+
finally:
193+
loop.run_until_complete(conn.close())
184194
else:
185195
pytest.fail("Cannot start memcached server")
186196

@@ -203,4 +213,4 @@ def memcached( # type: ignore[misc]
203213
) -> Iterator[aiomcache.Client]:
204214
conn = aiomcache.Client(loop=loop, **memcached_params)
205215
yield conn
206-
conn.close()
216+
loop.run_until_complete(conn.close())

tests/test_redis_storage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ async def handler(request: web.Request) -> web.StreamResponse:
290290

291291
redis = aioredis.from_url(redis_url) # type: ignore[no-untyped-call]
292292
create_app(handler=handler, redis=redis)
293+
await redis.close()
293294

294295

295296
async def test_not_redis_provided_to_storage() -> None:

0 commit comments

Comments
 (0)