Skip to content

Commit 6c41635

Browse files
committed
Remove compatibility code for asynccontextmanager
1 parent dbbe7a7 commit 6c41635

File tree

2 files changed

+1
-28
lines changed

2 files changed

+1
-28
lines changed

tests/test_asyncio/conftest.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22
import random
3-
from contextlib import asynccontextmanager as _asynccontextmanager
43
from datetime import datetime, timezone
54
from enum import Enum
65
from typing import Union
@@ -403,32 +402,6 @@ async def wait_for_command(
403402
return None
404403

405404

406-
# python 3.6 doesn't have the asynccontextmanager decorator. Provide it here.
407-
class AsyncContextManager:
408-
def __init__(self, async_generator):
409-
self.gen = async_generator
410-
411-
async def __aenter__(self):
412-
try:
413-
return await self.gen.__anext__()
414-
except StopAsyncIteration as err:
415-
raise RuntimeError("Pickles") from err
416-
417-
async def __aexit__(self, exc_type, exc_inst, tb):
418-
if exc_type:
419-
await self.gen.athrow(exc_type, exc_inst, tb)
420-
return True
421-
try:
422-
await self.gen.__anext__()
423-
except StopAsyncIteration:
424-
return
425-
raise RuntimeError("More pickles")
426-
427-
428-
def asynccontextmanager(func):
429-
return _asynccontextmanager(func)
430-
431-
432405
# helpers to get the connection arguments for this run
433406
@pytest.fixture()
434407
def redis_url(request):

tests/test_asyncio/test_connection_pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22
import re
3+
from contextlib import asynccontextmanager
34

45
import pytest
56
import pytest_asyncio
@@ -9,7 +10,6 @@
910
from tests.conftest import skip_if_redis_enterprise, skip_if_server_version_lt
1011

1112
from .compat import aclosing, mock
12-
from .conftest import asynccontextmanager
1313
from .test_pubsub import wait_for_message
1414

1515

0 commit comments

Comments
 (0)