@@ -42,7 +42,7 @@ def unused_port() -> int:
42
42
43
43
44
44
@pytest .fixture (scope = "session" )
45
- def loop () -> Iterator [asyncio .AbstractEventLoop ]:
45
+ def event_loop () -> Iterator [asyncio .AbstractEventLoop ]:
46
46
loop = asyncio .new_event_loop ()
47
47
asyncio .set_event_loop (None )
48
48
@@ -73,10 +73,10 @@ def docker() -> DockerClient: # type: ignore[misc] # No docker types.
73
73
def redis_server ( # type: ignore[misc] # No docker types.
74
74
docker : DockerClient ,
75
75
session_id : str ,
76
- loop : asyncio .AbstractEventLoop ,
76
+ event_loop : asyncio .AbstractEventLoop ,
77
77
) -> Iterator [_ContainerInfo ]:
78
78
image = "redis:{}" .format ("latest" )
79
- asyncio .set_event_loop (loop )
79
+ asyncio .set_event_loop (event_loop )
80
80
81
81
if sys .platform .startswith ("darwin" ):
82
82
port = unused_port ()
@@ -107,15 +107,15 @@ def redis_server( # type: ignore[misc] # No docker types.
107
107
for _i in range (20 ):
108
108
try :
109
109
conn = aioredis .from_url (f"redis://{ host } :{ port } " ) # type: ignore[no-untyped-call] # noqa
110
- loop .run_until_complete (conn .set ("foo" , "bar" ))
110
+ event_loop .run_until_complete (conn .set ("foo" , "bar" ))
111
111
break
112
112
except ConnectionError :
113
113
time .sleep (delay )
114
114
delay *= 2
115
115
finally :
116
- loop .run_until_complete (conn .close ())
116
+ event_loop .run_until_complete (conn .close ())
117
117
# TODO: Remove once fixed: github.com/aio-libs/aioredis-py/issues/1103
118
- loop .run_until_complete (conn .connection_pool .disconnect ())
118
+ event_loop .run_until_complete (conn .connection_pool .disconnect ())
119
119
else :
120
120
pytest .fail ("Cannot start redis server" )
121
121
@@ -132,25 +132,25 @@ def redis_url(redis_server: _ContainerInfo) -> str: # type: ignore[misc]
132
132
133
133
@pytest .fixture
134
134
def redis (
135
- loop : asyncio .AbstractEventLoop ,
135
+ event_loop : asyncio .AbstractEventLoop ,
136
136
redis_url : str ,
137
137
) -> Iterator [aioredis .Redis ]:
138
138
async def start (pool : aioredis .ConnectionPool ) -> aioredis .Redis :
139
139
return aioredis .Redis (connection_pool = pool )
140
140
141
- asyncio .set_event_loop (loop )
141
+ asyncio .set_event_loop (event_loop )
142
142
pool = aioredis .ConnectionPool .from_url (redis_url )
143
- redis = loop .run_until_complete (start (pool ))
143
+ redis = event_loop .run_until_complete (start (pool ))
144
144
yield redis
145
- loop .run_until_complete (redis .close ()) # type: ignore[no-untyped-call]
146
- loop .run_until_complete (pool .disconnect ())
145
+ event_loop .run_until_complete (redis .close ()) # type: ignore[no-untyped-call]
146
+ event_loop .run_until_complete (pool .disconnect ())
147
147
148
148
149
149
@pytest .fixture (scope = "session" )
150
150
def memcached_server ( # type: ignore[misc] # No docker types.
151
151
docker : DockerClient ,
152
152
session_id : str ,
153
- loop : asyncio .AbstractEventLoop ,
153
+ event_loop : asyncio .AbstractEventLoop ,
154
154
) -> Iterator [_ContainerInfo ]:
155
155
156
156
image = "memcached:{}" .format ("latest" )
@@ -183,14 +183,14 @@ def memcached_server( # type: ignore[misc] # No docker types.
183
183
delay = 0.1
184
184
for _i in range (20 ):
185
185
try :
186
- conn = aiomcache .Client (host , port , loop = loop )
187
- loop .run_until_complete (conn .set (b"foo" , b"bar" ))
186
+ conn = aiomcache .Client (host , port , loop = event_loop )
187
+ event_loop .run_until_complete (conn .set (b"foo" , b"bar" ))
188
188
break
189
189
except ConnectionRefusedError :
190
190
time .sleep (delay )
191
191
delay *= 2
192
192
finally :
193
- loop .run_until_complete (conn .close ())
193
+ event_loop .run_until_complete (conn .close ())
194
194
else :
195
195
pytest .fail ("Cannot start memcached server" )
196
196
@@ -209,8 +209,8 @@ def memcached_params( # type: ignore[misc]
209
209
210
210
@pytest .fixture
211
211
def memcached ( # type: ignore[misc]
212
- loop : asyncio .AbstractEventLoop , memcached_params : _MemcachedParams
212
+ event_loop : asyncio .AbstractEventLoop , memcached_params : _MemcachedParams
213
213
) -> Iterator [aiomcache .Client ]:
214
- conn = aiomcache .Client (loop = loop , ** memcached_params )
214
+ conn = aiomcache .Client (loop = event_loop , ** memcached_params )
215
215
yield conn
216
- loop .run_until_complete (conn .close ())
216
+ event_loop .run_until_complete (conn .close ())
0 commit comments