async def coro(): with contextvars.context_binding(b=2): contextvars.merge(event) assert event == { "a": 1, "b": 2, } assert "containerlog_b" in contextvars._CTXVARS assert contextvars._CTXVARS["containerlog_b"].get() == 2
async def coro(): contextvars.bind(a=5, b="foo") contextvars.bind(b="bar", c=False) contextvars.merge(event)
async def coro(): contextvars.bind(a=5, c=True) contextvars.merge(event)
async def coro(): contextvars.clear() contextvars.merge(event)
async def coro(): contextvars.bind(a=5, b="foo", c=False) contextvars.clear() contextvars.merge(event)
async def coro(): # unbinding does not explicitly remove the contextvar, it just sets it to # an ellipsis. to ensure the key was not previously set, add in some randomness. contextvars.unbind("%030x" % random.randrange(16**30)) contextvars.merge(event)
async def coro(): contextvars.bind(a=5) contextvars.unbind("a") contextvars.merge(event)
async def coro(): contextvars.bind(a=5, b="foo", c=False) contextvars.unbind("b") contextvars.merge(event)
async def coro3(): contextvars.bind(c=False) contextvars.merge(event)