gh-129874: improve asyncio tests to use correct internal functions (#129887)

This commit is contained in:
Kumar Aditya 2025-02-09 17:35:39 +05:30 committed by GitHub
parent c88dacb391
commit 09fe550ecc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 110 additions and 7 deletions

View file

@ -369,6 +369,8 @@ class TestCallStackC(CallStackTestBase, unittest.IsolatedAsyncioTestCase):
futures.future_discard_from_awaited_by = futures._c_future_discard_from_awaited_by
asyncio.future_discard_from_awaited_by = futures.future_discard_from_awaited_by
self._current_task = asyncio.current_task
asyncio.current_task = asyncio.tasks.current_task = tasks._c_current_task
def tearDown(self):
futures = asyncio.futures
@ -390,6 +392,8 @@ class TestCallStackC(CallStackTestBase, unittest.IsolatedAsyncioTestCase):
futures.Future = self._Future
del self._Future
asyncio.current_task = asyncio.tasks.current_task = self._current_task
@unittest.skipIf(
not hasattr(asyncio.futures, "_py_future_add_to_awaited_by"),
@ -414,6 +418,9 @@ class TestCallStackPy(CallStackTestBase, unittest.IsolatedAsyncioTestCase):
futures.future_discard_from_awaited_by = futures._py_future_discard_from_awaited_by
asyncio.future_discard_from_awaited_by = futures.future_discard_from_awaited_by
self._current_task = asyncio.current_task
asyncio.current_task = asyncio.tasks.current_task = tasks._py_current_task
def tearDown(self):
futures = asyncio.futures
@ -434,3 +441,5 @@ class TestCallStackPy(CallStackTestBase, unittest.IsolatedAsyncioTestCase):
asyncio.Future = self._Future
futures.Future = self._Future
del self._Future
asyncio.current_task = asyncio.tasks.current_task = self._current_task