Skip to content

Commit 4c248ab

Browse files
committed
refactor: Removed obsolete function _create_task_in_context
1 parent 0f6f6dc commit 4c248ab

File tree

1 file changed

+0
-24
lines changed

1 file changed

+0
-24
lines changed

pytest_asyncio/plugin.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from collections.abc import (
1717
AsyncIterator,
1818
Awaitable,
19-
Coroutine as AbstractCoroutine,
2019
Generator,
2120
Iterable,
2221
Iterator,
@@ -369,29 +368,6 @@ async def setup():
369368
return _async_fixture_wrapper
370369

371370

372-
def _create_task_in_context(
373-
loop: asyncio.AbstractEventLoop,
374-
coro: AbstractCoroutine[Any, Any, _T],
375-
context: contextvars.Context,
376-
) -> asyncio.Task[_T]:
377-
"""
378-
Return an asyncio task that runs the coro in the specified context,
379-
if possible.
380-
381-
This allows fixture setup and teardown to be run as separate asyncio tasks,
382-
while still being able to use context-manager idioms to maintain context
383-
variables and make those variables visible to test functions.
384-
385-
This is only fully supported on Python 3.11 and newer, as it requires
386-
the API added for https://github.com/python/cpython/issues/91150.
387-
On earlier versions, the returned task will use the default context instead.
388-
"""
389-
try:
390-
return loop.create_task(coro, context=context)
391-
except TypeError:
392-
return loop.create_task(coro)
393-
394-
395371
def _apply_contextvar_changes(
396372
context: contextvars.Context,
397373
) -> Callable[[], None] | None:

0 commit comments

Comments
 (0)