MCPcopy Create free account
hub / github.com/hynek/structlog / test_bind_unbind

Method test_bind_unbind

tests/test_stdlib.py:1613–1641  ·  view source on GitHub ↗

new/bind/unbind/try_unbind are correctly propagated.

(self, cl)

Source from the content-addressed store, hash-verified

1611
1612 @pytest.mark.asyncio
1613 async def test_bind_unbind(self, cl):
1614 """
1615 new/bind/unbind/try_unbind are correctly propagated.
1616 """
1617 l1 = AsyncBoundLogger(cl, context={}, processors=[])
1618
1619 l2 = l1.bind(x=42)
1620
1621 assert l1 is not l2
1622 assert l1.sync_bl is not l2.sync_bl
1623 assert {} == l1._context
1624 assert {"x": 42} == l2._context
1625
1626 l3 = l2.new(y=23)
1627
1628 assert l2 is not l3
1629 assert l2.sync_bl is not l3.sync_bl
1630 assert {"y": 23} == l3._context
1631
1632 l4 = l3.unbind("y")
1633
1634 assert {} == l4._context
1635 assert l3 is not l4
1636
1637 # N.B. x isn't bound anymore.
1638 l5 = l4.try_unbind("x")
1639
1640 assert {} == l5._context
1641 assert l4 is not l5
1642
1643 @pytest.mark.asyncio
1644 async def test_integration(self, capsys):

Callers

nothing calls this directly

Calls 5

bindMethod · 0.95
AsyncBoundLoggerClass · 0.90
newMethod · 0.45
unbindMethod · 0.45
try_unbindMethod · 0.45

Tested by

no test coverage detected