MCPcopy Create free account
hub / github.com/agronholm/anyio / test_custom_context

Method test_custom_context

tests/test_taskgroups.py:2267–2277  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2265 )
2266
2267 async def test_custom_context(self) -> None:
2268 ctxvar = ContextVar[int]("ctxvar")
2269 ctx = copy_context()
2270 ctx.run(ctxvar.set, 42)
2271
2272 async def taskfunc() -> int:
2273 return ctxvar.get()
2274
2275 assert ctxvar.get(None) is None
2276 async with create_task_group() as tg:
2277 assert await tg.create_task(taskfunc(), context=ctx) == 42
2278
2279 async def test_task_name_default(self) -> None:
2280 async def taskfunc() -> str | None:

Callers

nothing calls this directly

Calls 5

create_task_groupFunction · 0.90
taskfuncFunction · 0.85
getMethod · 0.80
runMethod · 0.45
create_taskMethod · 0.45

Tested by

no test coverage detected