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

Method test_bind_exc

tests/test_threadlocal.py:91–109  ·  view source on GitHub ↗

tmp_bind cleans up properly on exceptions.

(self, log)

Source from the content-addressed store, hash-verified

89 assert {"y": 23} == log._context._dict
90
91 def test_bind_exc(self, log):
92 """
93 tmp_bind cleans up properly on exceptions.
94 """
95 log = log.bind(y=23)
96
97 with ( # noqa: PT012
98 pytest.raises(CustomError),
99 pytest.deprecated_call(),
100 tmp_bind(log, x=42, y="foo") as tmp_log,
101 ):
102 assert (
103 {"y": "foo", "x": 42}
104 == tmp_log._context._dict
105 == log._context._dict
106 )
107 raise CustomError
108
109 assert {"y": 23} == log._context._dict
110
111 def test_tmp_bind_lazy(self):
112 """

Callers

nothing calls this directly

Calls 2

tmp_bindFunction · 0.90
bindMethod · 0.45

Tested by

no test coverage detected