1 |
commit: 0edc81fb7529ec388c628266d9584d6fb3464467 |
2 |
Author: Arthur Zamarin <arthurzam <AT> gmail <DOT> com> |
3 |
AuthorDate: Sat Jul 24 16:14:32 2021 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jul 29 18:46:51 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0edc81fb |
7 |
|
8 |
dev-python/async_timeout: enable py3.10 |
9 |
|
10 |
needed to import from upstream fixes for tests |
11 |
patch doesn't change other parts outside tests |
12 |
|
13 |
Signed-off-by: Arthur Zamarin <arthurzam <AT> gmail.com> |
14 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
15 |
|
16 |
.../async_timeout/async_timeout-3.0.1.ebuild | 6 +- |
17 |
.../files/async_timeout-3.0.1-fix-py3.10.patch | 387 +++++++++++++++++++++ |
18 |
2 files changed, 392 insertions(+), 1 deletion(-) |
19 |
|
20 |
diff --git a/dev-python/async_timeout/async_timeout-3.0.1.ebuild b/dev-python/async_timeout/async_timeout-3.0.1.ebuild |
21 |
index f4022958304..33755ac4a21 100644 |
22 |
--- a/dev-python/async_timeout/async_timeout-3.0.1.ebuild |
23 |
+++ b/dev-python/async_timeout/async_timeout-3.0.1.ebuild |
24 |
@@ -2,7 +2,8 @@ |
25 |
# Distributed under the terms of the GNU General Public License v2 |
26 |
|
27 |
EAPI=7 |
28 |
-PYTHON_COMPAT=( python3_{8..9} ) |
29 |
+ |
30 |
+PYTHON_COMPAT=( python3_{8..10} ) |
31 |
|
32 |
inherit distutils-r1 |
33 |
|
34 |
@@ -20,8 +21,11 @@ BDEPEND=" |
35 |
dev-python/setuptools_scm[${PYTHON_USEDEP}] |
36 |
test? ( |
37 |
dev-python/pytest-aiohttp[${PYTHON_USEDEP}] |
38 |
+ dev-python/pytest-asyncio[${PYTHON_USEDEP}] |
39 |
)" |
40 |
|
41 |
+PATCHES=( "${FILESDIR}/${P}-fix-py3.10.patch" ) |
42 |
+ |
43 |
distutils_enable_tests pytest |
44 |
|
45 |
python_prepare_all() { |
46 |
|
47 |
diff --git a/dev-python/async_timeout/files/async_timeout-3.0.1-fix-py3.10.patch b/dev-python/async_timeout/files/async_timeout-3.0.1-fix-py3.10.patch |
48 |
new file mode 100644 |
49 |
index 00000000000..5bfdcf2e6da |
50 |
--- /dev/null |
51 |
+++ b/dev-python/async_timeout/files/async_timeout-3.0.1-fix-py3.10.patch |
52 |
@@ -0,0 +1,387 @@ |
53 |
+diff --git a/tests/test_py35.py b/tests/test_py35.py |
54 |
+index 00bb7f0..7d88d99 100644 |
55 |
+--- a/tests/test_py35.py |
56 |
++++ b/tests/test_py35.py |
57 |
+@@ -4,30 +4,32 @@ import pytest |
58 |
+ |
59 |
+ from async_timeout import timeout |
60 |
+ |
61 |
+-pytestmark = pytest.mark.asyncio |
62 |
+ |
63 |
+- |
64 |
+-async def test_async_timeout(loop): |
65 |
++@×××××××××××.asyncio |
66 |
++async def test_async_timeout(): |
67 |
+ with pytest.raises(asyncio.TimeoutError): |
68 |
+- async with timeout(0.01, loop=loop) as cm: |
69 |
+- await asyncio.sleep(10, loop=loop) |
70 |
++ async with timeout(0.01) as cm: |
71 |
++ await asyncio.sleep(10) |
72 |
+ assert cm.expired |
73 |
+ |
74 |
+ |
75 |
+-async def test_async_no_timeout(loop): |
76 |
+- async with timeout(1, loop=loop) as cm: |
77 |
+- await asyncio.sleep(0, loop=loop) |
78 |
++@×××××××××××.asyncio |
79 |
++async def test_async_no_timeout(): |
80 |
++ async with timeout(1) as cm: |
81 |
++ await asyncio.sleep(0) |
82 |
+ assert not cm.expired |
83 |
+ |
84 |
+ |
85 |
+-async def test_async_zero(loop): |
86 |
++@×××××××××××.asyncio |
87 |
++async def test_async_zero(): |
88 |
+ with pytest.raises(asyncio.TimeoutError): |
89 |
+- async with timeout(0, loop=loop) as cm: |
90 |
+- await asyncio.sleep(10, loop=loop) |
91 |
++ async with timeout(0) as cm: |
92 |
++ await asyncio.sleep(10) |
93 |
+ assert cm.expired |
94 |
+ |
95 |
+ |
96 |
+-async def test_async_zero_coro_not_started(loop): |
97 |
++@×××××××××××.asyncio |
98 |
++async def test_async_zero_coro_not_started(): |
99 |
+ coro_started = False |
100 |
+ |
101 |
+ async def coro(): |
102 |
+@@ -35,8 +37,8 @@ async def test_async_zero_coro_not_started(loop): |
103 |
+ coro_started = True |
104 |
+ |
105 |
+ with pytest.raises(asyncio.TimeoutError): |
106 |
+- async with timeout(0, loop=loop) as cm: |
107 |
+- await asyncio.sleep(0, loop=loop) |
108 |
++ async with timeout(0) as cm: |
109 |
++ await asyncio.sleep(0) |
110 |
+ await coro() |
111 |
+ |
112 |
+ assert cm.expired |
113 |
+diff --git a/tests/test_timeout.py b/tests/test_timeout.py |
114 |
+index 8915546..b1cb3c7 100644 |
115 |
+--- a/tests/test_timeout.py |
116 |
++++ b/tests/test_timeout.py |
117 |
+@@ -6,89 +6,69 @@ import pytest |
118 |
+ |
119 |
+ from async_timeout import timeout |
120 |
+ |
121 |
+-from asyncio import ensure_future |
122 |
+- |
123 |
+- |
124 |
+-def create_future(loop): |
125 |
+- """Compatibility wrapper for the loop.create_future() call introduced in |
126 |
+- 3.5.2.""" |
127 |
+- if hasattr(loop, 'create_future'): |
128 |
+- return loop.create_future() |
129 |
+- else: |
130 |
+- return asyncio.Future(loop=loop) |
131 |
+- |
132 |
+ |
133 |
+ @pytest.mark.asyncio |
134 |
+-async def test_timeout(loop): |
135 |
++async def test_timeout(): |
136 |
+ canceled_raised = False |
137 |
+ |
138 |
+ async def long_running_task(): |
139 |
+ try: |
140 |
+- await asyncio.sleep(10, loop=loop) |
141 |
++ await asyncio.sleep(10) |
142 |
+ except asyncio.CancelledError: |
143 |
+ nonlocal canceled_raised |
144 |
+ canceled_raised = True |
145 |
+ raise |
146 |
+ |
147 |
+ with pytest.raises(asyncio.TimeoutError): |
148 |
+- with timeout(0.01, loop=loop) as t: |
149 |
++ with timeout(0.01) as t: |
150 |
+ await long_running_task() |
151 |
+- assert t._loop is loop |
152 |
++ assert t._loop is asyncio.get_event_loop() |
153 |
+ assert canceled_raised, 'CancelledError was not raised' |
154 |
+ |
155 |
+ |
156 |
+ @pytest.mark.asyncio |
157 |
+-async def test_timeout_finish_in_time(loop): |
158 |
++async def test_timeout_finish_in_time(): |
159 |
+ async def long_running_task(): |
160 |
+- await asyncio.sleep(0.01, loop=loop) |
161 |
++ await asyncio.sleep(0.01) |
162 |
+ return 'done' |
163 |
+ |
164 |
+- with timeout(0.1, loop=loop): |
165 |
++ with timeout(0.1): |
166 |
+ resp = await long_running_task() |
167 |
+ assert resp == 'done' |
168 |
+ |
169 |
+ |
170 |
+-def test_timeout_global_loop(loop): |
171 |
+- asyncio.set_event_loop(loop) |
172 |
+- |
173 |
+- async def run(): |
174 |
+- with timeout(10) as t: |
175 |
+- await asyncio.sleep(0.01) |
176 |
+- assert t._loop is loop |
177 |
+- |
178 |
+- loop.run_until_complete(run()) |
179 |
+- |
180 |
+- |
181 |
+ @pytest.mark.asyncio |
182 |
+-async def test_timeout_disable(loop): |
183 |
++async def test_timeout_disable(): |
184 |
+ async def long_running_task(): |
185 |
+- await asyncio.sleep(0.1, loop=loop) |
186 |
++ await asyncio.sleep(0.1) |
187 |
+ return 'done' |
188 |
+ |
189 |
++ loop = asyncio.get_event_loop() |
190 |
+ t0 = loop.time() |
191 |
+- with timeout(None, loop=loop): |
192 |
++ with timeout(None): |
193 |
+ resp = await long_running_task() |
194 |
+ assert resp == 'done' |
195 |
+ dt = loop.time() - t0 |
196 |
+ assert 0.09 < dt < 0.13, dt |
197 |
+ |
198 |
+ |
199 |
+-def test_timeout_is_none_no_task(loop): |
200 |
++def test_timeout_is_none_no_task(): |
201 |
++ loop = asyncio.get_event_loop() |
202 |
+ with timeout(None, loop=loop) as cm: |
203 |
+ assert cm._task is None |
204 |
+ |
205 |
+ |
206 |
+ @pytest.mark.asyncio |
207 |
+-async def test_timeout_enable_zero(loop): |
208 |
++async def test_timeout_enable_zero(): |
209 |
+ with pytest.raises(asyncio.TimeoutError): |
210 |
+- with timeout(0, loop=loop) as cm: |
211 |
+- await asyncio.sleep(0.1, loop=loop) |
212 |
++ with timeout(0) as cm: |
213 |
++ await asyncio.sleep(0.1) |
214 |
+ |
215 |
+ assert cm.expired |
216 |
+ |
217 |
+ |
218 |
+ @pytest.mark.asyncio |
219 |
+-async def test_timeout_enable_zero_coro_not_started(loop): |
220 |
++async def test_timeout_enable_zero_coro_not_started(): |
221 |
+ coro_started = False |
222 |
+ |
223 |
+ async def coro(): |
224 |
+@@ -96,8 +76,8 @@ async def test_timeout_enable_zero_coro_not_started(loop): |
225 |
+ coro_started = True |
226 |
+ |
227 |
+ with pytest.raises(asyncio.TimeoutError): |
228 |
+- with timeout(0, loop=loop) as cm: |
229 |
+- await asyncio.sleep(0, loop=loop) |
230 |
++ with timeout(0) as cm: |
231 |
++ await asyncio.sleep(0) |
232 |
+ await coro() |
233 |
+ |
234 |
+ assert cm.expired |
235 |
+@@ -105,51 +85,52 @@ async def test_timeout_enable_zero_coro_not_started(loop): |
236 |
+ |
237 |
+ |
238 |
+ @pytest.mark.asyncio |
239 |
+-async def test_timeout_not_relevant_exception(loop): |
240 |
+- await asyncio.sleep(0, loop=loop) |
241 |
++async def test_timeout_not_relevant_exception(): |
242 |
++ await asyncio.sleep(0) |
243 |
+ with pytest.raises(KeyError): |
244 |
+- with timeout(0.1, loop=loop): |
245 |
++ with timeout(0.1): |
246 |
+ raise KeyError |
247 |
+ |
248 |
+ |
249 |
+ @pytest.mark.asyncio |
250 |
+-async def test_timeout_canceled_error_is_not_converted_to_timeout(loop): |
251 |
+- await asyncio.sleep(0, loop=loop) |
252 |
++async def test_timeout_canceled_error_is_not_converted_to_timeout(): |
253 |
++ await asyncio.sleep(0) |
254 |
+ with pytest.raises(asyncio.CancelledError): |
255 |
+- with timeout(0.001, loop=loop): |
256 |
++ with timeout(0.001): |
257 |
+ raise asyncio.CancelledError |
258 |
+ |
259 |
+ |
260 |
+ @pytest.mark.asyncio |
261 |
+-async def test_timeout_blocking_loop(loop): |
262 |
++async def test_timeout_blocking_loop(): |
263 |
+ async def long_running_task(): |
264 |
+ time.sleep(0.1) |
265 |
+ return 'done' |
266 |
+ |
267 |
+- with timeout(0.01, loop=loop): |
268 |
++ with timeout(0.01): |
269 |
+ result = await long_running_task() |
270 |
+ assert result == 'done' |
271 |
+ |
272 |
+ |
273 |
+ @pytest.mark.asyncio |
274 |
+-async def test_for_race_conditions(loop): |
275 |
+- fut = create_future(loop) |
276 |
++async def test_for_race_conditions(): |
277 |
++ loop = asyncio.get_event_loop() |
278 |
++ fut = loop.create_future() |
279 |
+ loop.call_later(0.1, fut.set_result('done')) |
280 |
+- with timeout(0.2, loop=loop): |
281 |
++ with timeout(0.2): |
282 |
+ resp = await fut |
283 |
+ assert resp == 'done' |
284 |
+ |
285 |
+ |
286 |
+ @pytest.mark.asyncio |
287 |
+-async def test_timeout_time(loop): |
288 |
++async def test_timeout_time(): |
289 |
+ foo_running = None |
290 |
+- |
291 |
++ loop = asyncio.get_event_loop() |
292 |
+ start = loop.time() |
293 |
+ with pytest.raises(asyncio.TimeoutError): |
294 |
+- with timeout(0.1, loop=loop): |
295 |
++ with timeout(0.1): |
296 |
+ foo_running = True |
297 |
+ try: |
298 |
+- await asyncio.sleep(0.2, loop=loop) |
299 |
++ await asyncio.sleep(0.2) |
300 |
+ finally: |
301 |
+ foo_running = False |
302 |
+ |
303 |
+@@ -160,26 +141,26 @@ async def test_timeout_time(loop): |
304 |
+ assert not foo_running |
305 |
+ |
306 |
+ |
307 |
+-def test_raise_runtimeerror_if_no_task(loop): |
308 |
++def test_raise_runtimeerror_if_no_task(): |
309 |
+ with pytest.raises(RuntimeError): |
310 |
+- with timeout(0.1, loop=loop): |
311 |
++ with timeout(0.1): |
312 |
+ pass |
313 |
+ |
314 |
+ |
315 |
+ @pytest.mark.asyncio |
316 |
+-async def test_outer_coro_is_not_cancelled(loop): |
317 |
++async def test_outer_coro_is_not_cancelled(): |
318 |
+ |
319 |
+ has_timeout = False |
320 |
+ |
321 |
+ async def outer(): |
322 |
+ nonlocal has_timeout |
323 |
+ try: |
324 |
+- with timeout(0.001, loop=loop): |
325 |
+- await asyncio.sleep(1, loop=loop) |
326 |
++ with timeout(0.001): |
327 |
++ await asyncio.sleep(1) |
328 |
+ except asyncio.TimeoutError: |
329 |
+ has_timeout = True |
330 |
+ |
331 |
+- task = ensure_future(outer(), loop=loop) |
332 |
++ task = asyncio.ensure_future(outer()) |
333 |
+ await task |
334 |
+ assert has_timeout |
335 |
+ assert not task.cancelled() |
336 |
+@@ -187,14 +168,15 @@ async def test_outer_coro_is_not_cancelled(loop): |
337 |
+ |
338 |
+ |
339 |
+ @pytest.mark.asyncio |
340 |
+-async def test_cancel_outer_coro(loop): |
341 |
+- fut = create_future(loop) |
342 |
++async def test_cancel_outer_coro(): |
343 |
++ loop = asyncio.get_event_loop() |
344 |
++ fut = loop.create_future() |
345 |
+ |
346 |
+ async def outer(): |
347 |
+ fut.set_result(None) |
348 |
+- await asyncio.sleep(1, loop=loop) |
349 |
++ await asyncio.sleep(1) |
350 |
+ |
351 |
+- task = ensure_future(outer(), loop=loop) |
352 |
++ task = asyncio.ensure_future(outer()) |
353 |
+ await fut |
354 |
+ task.cancel() |
355 |
+ with pytest.raises(asyncio.CancelledError): |
356 |
+@@ -204,57 +186,64 @@ async def test_cancel_outer_coro(loop): |
357 |
+ |
358 |
+ |
359 |
+ @pytest.mark.asyncio |
360 |
+-async def test_timeout_suppress_exception_chain(loop): |
361 |
++async def test_timeout_suppress_exception_chain(): |
362 |
+ with pytest.raises(asyncio.TimeoutError) as ctx: |
363 |
+- with timeout(0.01, loop=loop): |
364 |
+- await asyncio.sleep(10, loop=loop) |
365 |
++ with timeout(0.01): |
366 |
++ await asyncio.sleep(10) |
367 |
+ assert not ctx.value.__suppress_context__ |
368 |
+ |
369 |
+ |
370 |
+ @pytest.mark.asyncio |
371 |
+-async def test_timeout_expired(loop): |
372 |
++async def test_timeout_expired(): |
373 |
+ with pytest.raises(asyncio.TimeoutError): |
374 |
+- with timeout(0.01, loop=loop) as cm: |
375 |
+- await asyncio.sleep(10, loop=loop) |
376 |
++ with timeout(0.01) as cm: |
377 |
++ await asyncio.sleep(10) |
378 |
+ assert cm.expired |
379 |
+ |
380 |
+ |
381 |
+ @pytest.mark.asyncio |
382 |
+-async def test_timeout_inner_timeout_error(loop): |
383 |
++async def test_timeout_inner_timeout_error(): |
384 |
+ with pytest.raises(asyncio.TimeoutError): |
385 |
+- with timeout(0.01, loop=loop) as cm: |
386 |
++ with timeout(0.01) as cm: |
387 |
+ raise asyncio.TimeoutError |
388 |
+ assert not cm.expired |
389 |
+ |
390 |
+ |
391 |
+ @pytest.mark.asyncio |
392 |
+-async def test_timeout_inner_other_error(loop): |
393 |
++async def test_timeout_inner_other_error(): |
394 |
+ with pytest.raises(RuntimeError): |
395 |
+- with timeout(0.01, loop=loop) as cm: |
396 |
++ with timeout(0.01) as cm: |
397 |
+ raise RuntimeError |
398 |
+ assert not cm.expired |
399 |
+ |
400 |
+ |
401 |
+ @pytest.mark.asyncio |
402 |
+-async def test_timeout_remaining(loop): |
403 |
+- with timeout(None, loop=loop) as cm: |
404 |
++async def test_timeout_remaining(): |
405 |
++ with timeout(None) as cm: |
406 |
+ assert cm.remaining is None |
407 |
++ assert cm.remaining is None |
408 |
++ |
409 |
++ t = timeout(None) |
410 |
++ assert t.remaining is None |
411 |
+ |
412 |
+- t = timeout(1.0, loop=loop) |
413 |
++ t = timeout(1.0) |
414 |
+ assert t.remaining is None |
415 |
+ |
416 |
+- with timeout(1.0, loop=loop) as cm: |
417 |
+- await asyncio.sleep(0.1, loop=loop) |
418 |
++ with timeout(1.0) as cm: |
419 |
++ await asyncio.sleep(0.1) |
420 |
+ assert cm.remaining < 1.0 |
421 |
++ r = cm.remaining |
422 |
++ time.sleep(0.1) |
423 |
++ assert abs(r - cm.remaining) < 1.0 |
424 |
+ |
425 |
+ with pytest.raises(asyncio.TimeoutError): |
426 |
+- with timeout(0.1, loop=loop) as cm: |
427 |
+- await asyncio.sleep(0.5, loop=loop) |
428 |
++ with timeout(0.1) as cm: |
429 |
++ await asyncio.sleep(0.5) |
430 |
+ |
431 |
+ assert cm.remaining == 0.0 |
432 |
+ |
433 |
+ |
434 |
+-def test_cancel_without_starting(loop): |
435 |
+- tm = timeout(1, loop=loop) |
436 |
++def test_cancel_without_starting(): |
437 |
++ tm = timeout(1) |
438 |
+ tm._cancel_task() |
439 |
+ tm._cancel_task() # double call should success |