MCPcopy Create free account
hub / github.com/MagicStack/contextvars / test_context_getset_5

Method test_context_getset_5

tests/test_basics.py:303–313  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

301
302 @isolated_context
303 def test_context_getset_5(self):
304 c = contextvars.ContextVar('c', default=42)
305 c.set([])
306
307 def fun():
308 c.set([])
309 c.get().append(42)
310 self.assertEqual(c.get(), [42])
311
312 contextvars.copy_context().run(fun)
313 self.assertEqual(c.get(), [])
314
315 def test_context_copy_1(self):
316 ctx1 = contextvars.Context()

Callers

nothing calls this directly

Calls 3

setMethod · 0.95
getMethod · 0.95
runMethod · 0.80

Tested by

no test coverage detected