Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/MagicStack/contextvars
/ fun
Method
fun
tests/test_basics.py:185–191 ·
view source on GitHub ↗
()
Source
from the content-addressed store, hash-verified
183
c = contextvars.ContextVar(
'a'
, default=0)
184
185
def
fun():
186
self.assertEqual(c.get(), 0)
187
self.assertIsNone(ctx.get(c))
188
189
c.set(42)
190
self.assertEqual(c.get(), 42)
191
self.assertEqual(ctx.get(c), 42)
192
193
ctx.run(fun)
194
Callers
nothing calls this directly
Calls
4
get
Method · 0.80
set
Method · 0.80
run
Method · 0.80
reset
Method · 0.80
Tested by
no test coverage detected