|
16 | 16 | from collections.abc import ( |
17 | 17 | AsyncIterator, |
18 | 18 | Awaitable, |
19 | | - Coroutine as AbstractCoroutine, |
20 | 19 | Generator, |
21 | 20 | Iterable, |
22 | 21 | Iterator, |
@@ -369,29 +368,6 @@ async def setup(): |
369 | 368 | return _async_fixture_wrapper |
370 | 369 |
|
371 | 370 |
|
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 | | - |
395 | 371 | def _apply_contextvar_changes( |
396 | 372 | context: contextvars.Context, |
397 | 373 | ) -> Callable[[], None] | None: |
|
0 commit comments