summaryrefslogtreecommitdiff
path: root/dev-python/async_timeout
diff options
context:
space:
mode:
Diffstat (limited to 'dev-python/async_timeout')
-rw-r--r--dev-python/async_timeout/Manifest3
-rw-r--r--dev-python/async_timeout/async_timeout-3.0.1.ebuild6
-rw-r--r--dev-python/async_timeout/files/async_timeout-3.0.1-fix-py3.10.patch387
3 files changed, 394 insertions, 2 deletions
diff --git a/dev-python/async_timeout/Manifest b/dev-python/async_timeout/Manifest
index 4d930d9dd053..99f09c149359 100644
--- a/dev-python/async_timeout/Manifest
+++ b/dev-python/async_timeout/Manifest
@@ -1,3 +1,4 @@
+AUX async_timeout-3.0.1-fix-py3.10.patch 11203 BLAKE2B dab3b3e09832ed11a9c684aaa3c21f2294f0066a740ebda047ae8b550c72caa1624b30520870989ec2cebedb72a8e556a92aeea0652411afc16ffab1ca2d825a SHA512 80249589c7f2f2f7c914bef7bf6fb3f03bc9a7d8dfd3376307baf85df28f3240381ca3a580091d1aa1aa9fa4f360ae5d92a5e1b46c308ac0c7e0d857b9d6648d
DIST async-timeout-3.0.1.tar.gz 9724 BLAKE2B f18ae75969b7048469fe22949f25ea25da3fdbf08b98a16b5d5ffe823060a75e6de9ed764727e08d4344c79426e9c89013d49522f20ed62e6fbe912b5c7a8787 SHA512 fd30842671a79edfd52c7350e7fb2120533a6d97b44975f7b071ce2cbde43443bd5bbe1f2ad0ad3ab2156e1987b9e58e0c149b0ecfea8674eb0cb78eee79c986
-EBUILD async_timeout-3.0.1.ebuild 871 BLAKE2B bda191eddd234253a261c84e960c30ab3e46e6fb7aacf58c0999342b9689acf390241753fd62404643bdf30825baca66cdb6f9a8ec7254018d54ea8f23a807eb SHA512 f25e0b023d609c69764e0f5dff99ce709183261398eb2f4e3c067763fd5a03661de8e4fc406a920dc0b9de72bf0b2f8bbe94b402ffa2e9fdfc134ad9c85ca247
+EBUILD async_timeout-3.0.1.ebuild 968 BLAKE2B 1796e2c00b629edd090b88a3b6cff4e3a20190351d1ae105c0cb16581f0a353e388f3274d6693612cf2df95bf95ab495dd7cfb55088594827fa300cf56c778e0 SHA512 16aa8169ceb211ef74631b180083cc9d900b13016f0a90c363aec91832b00051c25712e610b2aabad7fcc443e4ed566b53a8c663e13b963b856ae6e3e5387b2f
MISC metadata.xml 459 BLAKE2B aa3214d8a14324f68b5743f51371cf1902962a5b14bb7065a04944684d33f9639edbc9a899f5cd02ca19068506c5e403db149742d0b1cedf8e35a5927a837901 SHA512 fb0488558b0e1d7b9e0721a7d299bf2d105d66c67f51ea1bdb1b8dc529bb3a964c89d4410ee8640d0b094d1e364e5d59d8a9b7bafb0cdd9f3dde6443c0d46a15
diff --git a/dev-python/async_timeout/async_timeout-3.0.1.ebuild b/dev-python/async_timeout/async_timeout-3.0.1.ebuild
index f4022958304b..33755ac4a219 100644
--- a/dev-python/async_timeout/async_timeout-3.0.1.ebuild
+++ b/dev-python/async_timeout/async_timeout-3.0.1.ebuild
@@ -2,7 +2,8 @@
# Distributed under the terms of the GNU General Public License v2
EAPI=7
-PYTHON_COMPAT=( python3_{8..9} )
+
+PYTHON_COMPAT=( python3_{8..10} )
inherit distutils-r1
@@ -20,8 +21,11 @@ BDEPEND="
dev-python/setuptools_scm[${PYTHON_USEDEP}]
test? (
dev-python/pytest-aiohttp[${PYTHON_USEDEP}]
+ dev-python/pytest-asyncio[${PYTHON_USEDEP}]
)"
+PATCHES=( "${FILESDIR}/${P}-fix-py3.10.patch" )
+
distutils_enable_tests pytest
python_prepare_all() {
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
new file mode 100644
index 000000000000..5bfdcf2e6dab
--- /dev/null
+++ b/dev-python/async_timeout/files/async_timeout-3.0.1-fix-py3.10.patch
@@ -0,0 +1,387 @@
+diff --git a/tests/test_py35.py b/tests/test_py35.py
+index 00bb7f0..7d88d99 100644
+--- a/tests/test_py35.py
++++ b/tests/test_py35.py
+@@ -4,30 +4,32 @@ import pytest
+
+ from async_timeout import timeout
+
+-pytestmark = pytest.mark.asyncio
+
+-
+-async def test_async_timeout(loop):
++@pytest.mark.asyncio
++async def test_async_timeout():
+ with pytest.raises(asyncio.TimeoutError):
+- async with timeout(0.01, loop=loop) as cm:
+- await asyncio.sleep(10, loop=loop)
++ async with timeout(0.01) as cm:
++ await asyncio.sleep(10)
+ assert cm.expired
+
+
+-async def test_async_no_timeout(loop):
+- async with timeout(1, loop=loop) as cm:
+- await asyncio.sleep(0, loop=loop)
++@pytest.mark.asyncio
++async def test_async_no_timeout():
++ async with timeout(1) as cm:
++ await asyncio.sleep(0)
+ assert not cm.expired
+
+
+-async def test_async_zero(loop):
++@pytest.mark.asyncio
++async def test_async_zero():
+ with pytest.raises(asyncio.TimeoutError):
+- async with timeout(0, loop=loop) as cm:
+- await asyncio.sleep(10, loop=loop)
++ async with timeout(0) as cm:
++ await asyncio.sleep(10)
+ assert cm.expired
+
+
+-async def test_async_zero_coro_not_started(loop):
++@pytest.mark.asyncio
++async def test_async_zero_coro_not_started():
+ coro_started = False
+
+ async def coro():
+@@ -35,8 +37,8 @@ async def test_async_zero_coro_not_started(loop):
+ coro_started = True
+
+ with pytest.raises(asyncio.TimeoutError):
+- async with timeout(0, loop=loop) as cm:
+- await asyncio.sleep(0, loop=loop)
++ async with timeout(0) as cm:
++ await asyncio.sleep(0)
+ await coro()
+
+ assert cm.expired
+diff --git a/tests/test_timeout.py b/tests/test_timeout.py
+index 8915546..b1cb3c7 100644
+--- a/tests/test_timeout.py
++++ b/tests/test_timeout.py
+@@ -6,89 +6,69 @@ import pytest
+
+ from async_timeout import timeout
+
+-from asyncio import ensure_future
+-
+-
+-def create_future(loop):
+- """Compatibility wrapper for the loop.create_future() call introduced in
+- 3.5.2."""
+- if hasattr(loop, 'create_future'):
+- return loop.create_future()
+- else:
+- return asyncio.Future(loop=loop)
+-
+
+ @pytest.mark.asyncio
+-async def test_timeout(loop):
++async def test_timeout():
+ canceled_raised = False
+
+ async def long_running_task():
+ try:
+- await asyncio.sleep(10, loop=loop)
++ await asyncio.sleep(10)
+ except asyncio.CancelledError:
+ nonlocal canceled_raised
+ canceled_raised = True
+ raise
+
+ with pytest.raises(asyncio.TimeoutError):
+- with timeout(0.01, loop=loop) as t:
++ with timeout(0.01) as t:
+ await long_running_task()
+- assert t._loop is loop
++ assert t._loop is asyncio.get_event_loop()
+ assert canceled_raised, 'CancelledError was not raised'
+
+
+ @pytest.mark.asyncio
+-async def test_timeout_finish_in_time(loop):
++async def test_timeout_finish_in_time():
+ async def long_running_task():
+- await asyncio.sleep(0.01, loop=loop)
++ await asyncio.sleep(0.01)
+ return 'done'
+
+- with timeout(0.1, loop=loop):
++ with timeout(0.1):
+ resp = await long_running_task()
+ assert resp == 'done'
+
+
+-def test_timeout_global_loop(loop):
+- asyncio.set_event_loop(loop)
+-
+- async def run():
+- with timeout(10) as t:
+- await asyncio.sleep(0.01)
+- assert t._loop is loop
+-
+- loop.run_until_complete(run())
+-
+-
+ @pytest.mark.asyncio
+-async def test_timeout_disable(loop):
++async def test_timeout_disable():
+ async def long_running_task():
+- await asyncio.sleep(0.1, loop=loop)
++ await asyncio.sleep(0.1)
+ return 'done'
+
++ loop = asyncio.get_event_loop()
+ t0 = loop.time()
+- with timeout(None, loop=loop):
++ with timeout(None):
+ resp = await long_running_task()
+ assert resp == 'done'
+ dt = loop.time() - t0
+ assert 0.09 < dt < 0.13, dt
+
+
+-def test_timeout_is_none_no_task(loop):
++def test_timeout_is_none_no_task():
++ loop = asyncio.get_event_loop()
+ with timeout(None, loop=loop) as cm:
+ assert cm._task is None
+
+
+ @pytest.mark.asyncio
+-async def test_timeout_enable_zero(loop):
++async def test_timeout_enable_zero():
+ with pytest.raises(asyncio.TimeoutError):
+- with timeout(0, loop=loop) as cm:
+- await asyncio.sleep(0.1, loop=loop)
++ with timeout(0) as cm:
++ await asyncio.sleep(0.1)
+
+ assert cm.expired
+
+
+ @pytest.mark.asyncio
+-async def test_timeout_enable_zero_coro_not_started(loop):
++async def test_timeout_enable_zero_coro_not_started():
+ coro_started = False
+
+ async def coro():
+@@ -96,8 +76,8 @@ async def test_timeout_enable_zero_coro_not_started(loop):
+ coro_started = True
+
+ with pytest.raises(asyncio.TimeoutError):
+- with timeout(0, loop=loop) as cm:
+- await asyncio.sleep(0, loop=loop)
++ with timeout(0) as cm:
++ await asyncio.sleep(0)
+ await coro()
+
+ assert cm.expired
+@@ -105,51 +85,52 @@ async def test_timeout_enable_zero_coro_not_started(loop):
+
+
+ @pytest.mark.asyncio
+-async def test_timeout_not_relevant_exception(loop):
+- await asyncio.sleep(0, loop=loop)
++async def test_timeout_not_relevant_exception():
++ await asyncio.sleep(0)
+ with pytest.raises(KeyError):
+- with timeout(0.1, loop=loop):
++ with timeout(0.1):
+ raise KeyError
+
+
+ @pytest.mark.asyncio
+-async def test_timeout_canceled_error_is_not_converted_to_timeout(loop):
+- await asyncio.sleep(0, loop=loop)
++async def test_timeout_canceled_error_is_not_converted_to_timeout():
++ await asyncio.sleep(0)
+ with pytest.raises(asyncio.CancelledError):
+- with timeout(0.001, loop=loop):
++ with timeout(0.001):
+ raise asyncio.CancelledError
+
+
+ @pytest.mark.asyncio
+-async def test_timeout_blocking_loop(loop):
++async def test_timeout_blocking_loop():
+ async def long_running_task():
+ time.sleep(0.1)
+ return 'done'
+
+- with timeout(0.01, loop=loop):
++ with timeout(0.01):
+ result = await long_running_task()
+ assert result == 'done'
+
+
+ @pytest.mark.asyncio
+-async def test_for_race_conditions(loop):
+- fut = create_future(loop)
++async def test_for_race_conditions():
++ loop = asyncio.get_event_loop()
++ fut = loop.create_future()
+ loop.call_later(0.1, fut.set_result('done'))
+- with timeout(0.2, loop=loop):
++ with timeout(0.2):
+ resp = await fut
+ assert resp == 'done'
+
+
+ @pytest.mark.asyncio
+-async def test_timeout_time(loop):
++async def test_timeout_time():
+ foo_running = None
+-
++ loop = asyncio.get_event_loop()
+ start = loop.time()
+ with pytest.raises(asyncio.TimeoutError):
+- with timeout(0.1, loop=loop):
++ with timeout(0.1):
+ foo_running = True
+ try:
+- await asyncio.sleep(0.2, loop=loop)
++ await asyncio.sleep(0.2)
+ finally:
+ foo_running = False
+
+@@ -160,26 +141,26 @@ async def test_timeout_time(loop):
+ assert not foo_running
+
+
+-def test_raise_runtimeerror_if_no_task(loop):
++def test_raise_runtimeerror_if_no_task():
+ with pytest.raises(RuntimeError):
+- with timeout(0.1, loop=loop):
++ with timeout(0.1):
+ pass
+
+
+ @pytest.mark.asyncio
+-async def test_outer_coro_is_not_cancelled(loop):
++async def test_outer_coro_is_not_cancelled():
+
+ has_timeout = False
+
+ async def outer():
+ nonlocal has_timeout
+ try:
+- with timeout(0.001, loop=loop):
+- await asyncio.sleep(1, loop=loop)
++ with timeout(0.001):
++ await asyncio.sleep(1)
+ except asyncio.TimeoutError:
+ has_timeout = True
+
+- task = ensure_future(outer(), loop=loop)
++ task = asyncio.ensure_future(outer())
+ await task
+ assert has_timeout
+ assert not task.cancelled()
+@@ -187,14 +168,15 @@ async def test_outer_coro_is_not_cancelled(loop):
+
+
+ @pytest.mark.asyncio
+-async def test_cancel_outer_coro(loop):
+- fut = create_future(loop)
++async def test_cancel_outer_coro():
++ loop = asyncio.get_event_loop()
++ fut = loop.create_future()
+
+ async def outer():
+ fut.set_result(None)
+- await asyncio.sleep(1, loop=loop)
++ await asyncio.sleep(1)
+
+- task = ensure_future(outer(), loop=loop)
++ task = asyncio.ensure_future(outer())
+ await fut
+ task.cancel()
+ with pytest.raises(asyncio.CancelledError):
+@@ -204,57 +186,64 @@ async def test_cancel_outer_coro(loop):
+
+
+ @pytest.mark.asyncio
+-async def test_timeout_suppress_exception_chain(loop):
++async def test_timeout_suppress_exception_chain():
+ with pytest.raises(asyncio.TimeoutError) as ctx:
+- with timeout(0.01, loop=loop):
+- await asyncio.sleep(10, loop=loop)
++ with timeout(0.01):
++ await asyncio.sleep(10)
+ assert not ctx.value.__suppress_context__
+
+
+ @pytest.mark.asyncio
+-async def test_timeout_expired(loop):
++async def test_timeout_expired():
+ with pytest.raises(asyncio.TimeoutError):
+- with timeout(0.01, loop=loop) as cm:
+- await asyncio.sleep(10, loop=loop)
++ with timeout(0.01) as cm:
++ await asyncio.sleep(10)
+ assert cm.expired
+
+
+ @pytest.mark.asyncio
+-async def test_timeout_inner_timeout_error(loop):
++async def test_timeout_inner_timeout_error():
+ with pytest.raises(asyncio.TimeoutError):
+- with timeout(0.01, loop=loop) as cm:
++ with timeout(0.01) as cm:
+ raise asyncio.TimeoutError
+ assert not cm.expired
+
+
+ @pytest.mark.asyncio
+-async def test_timeout_inner_other_error(loop):
++async def test_timeout_inner_other_error():
+ with pytest.raises(RuntimeError):
+- with timeout(0.01, loop=loop) as cm:
++ with timeout(0.01) as cm:
+ raise RuntimeError
+ assert not cm.expired
+
+
+ @pytest.mark.asyncio
+-async def test_timeout_remaining(loop):
+- with timeout(None, loop=loop) as cm:
++async def test_timeout_remaining():
++ with timeout(None) as cm:
+ assert cm.remaining is None
++ assert cm.remaining is None
++
++ t = timeout(None)
++ assert t.remaining is None
+
+- t = timeout(1.0, loop=loop)
++ t = timeout(1.0)
+ assert t.remaining is None
+
+- with timeout(1.0, loop=loop) as cm:
+- await asyncio.sleep(0.1, loop=loop)
++ with timeout(1.0) as cm:
++ await asyncio.sleep(0.1)
+ assert cm.remaining < 1.0
++ r = cm.remaining
++ time.sleep(0.1)
++ assert abs(r - cm.remaining) < 1.0
+
+ with pytest.raises(asyncio.TimeoutError):
+- with timeout(0.1, loop=loop) as cm:
+- await asyncio.sleep(0.5, loop=loop)
++ with timeout(0.1) as cm:
++ await asyncio.sleep(0.5)
+
+ assert cm.remaining == 0.0
+
+
+-def test_cancel_without_starting(loop):
+- tm = timeout(1, loop=loop)
++def test_cancel_without_starting():
++ tm = timeout(1)
+ tm._cancel_task()
+ tm._cancel_task() # double call should success